Include - unlimited decimals
Posted: Tue Dec 22, 2009 2:41 am
Here's a little Include in Germany
Decimal.pbi
Original Topic here
This include allows you to calculat on unlimited decimals (both pure-integer and non-integer, positive and negative)
The include does not work with strings probes with long-arrays, making it much faster
Here are a few examples:
It is also important after surgery that currently the numbers you were involved in it are deleted, that will protect against buffer overflows, but can be suppressed with a parameter if you need the numbers yet again!
Note: The square root is still very slow, it wil be made through iteration
a detailed help in English and German will come later
Decimal.pbi
Original Topic here
This include allows you to calculat on unlimited decimals (both pure-integer and non-integer, positive and negative)
The include does not work with strings probes with long-arrays, making it much faster
Here are a few examples:
Code: Select all
Debug "Times"
*Zahl1 = StringToDecimal("12345678901234567890.12345678901234567890")
*Zahl2 = StringToDecimal("98765432109876543210.98765432109876543210")
Debug DecimalToString(*Zahl1, #NoDecimal)
Debug DecimalToString(*Zahl2, #NoDecimal)
*Ergebnis0 = TimesDecimal(*Zahl1, *Zahl2)
Debug ">> "+DecimalToString(*Ergebnis0)
Debug ""
Debug "Factorial 1000"
Debug ">> "+DecimalToString(FactorialDecimal(IntegerToDecimal(1000)))
Debug ""
Debug "1024 ^ 1024"
*Ergebnis = PowerDecimal(IntegerToDecimal(1024), IntegerToDecimal(1024))
Debug ">> "+DecimalToString(*Ergebnis)
Debug ""
Debug "2.56^1000 / 2.56^998"
*Zahl1 = PowerDecimal(StringToDecimal("2.56"), IntegerToDecimal(1000))
*Zahl2 = PowerDecimal(StringToDecimal("2.56"), IntegerToDecimal(998))
Debug DecimalToString(*Zahl1, #NoDecimal)
Debug DecimalToString(*Zahl2, #NoDecimal)
*Ergebnis2 = DivideDecimal(*Zahl1, *Zahl2, 10)
Debug ">> "+DecimalToString(*Ergebnis2)
Debug ""
Debug "greatest common divisor of two large numbers with decimals"
*Zahl1 = StringToDecimal("140032456034604564060345063546.25")
*Zahl2 = StringToDecimal("74356367865484675647864667768.75")
*Ergebnis3 = GCDDecimal(*Zahl1, *Zahl2)
Debug ">> "+DecimalToString(*Ergebnis3)
Note: The square root is still very slow, it wil be made through iteration
a detailed help in English and German will come later