Page 1 of 1

Include - unlimited decimals

Posted: Tue Dec 22, 2009 2:41 am
by STARGÅTE
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:

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)
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

Re: Include - unlimited decimals

Posted: Tue Dec 22, 2009 9:52 am
by Fred
very interesting !

Re: Include - unlimited decimals

Posted: Tue Dec 22, 2009 6:14 pm
by Michael Vogel
Nice, looks a little bit like an advanced version of VNF :wink:

Michael

Re: Include - unlimited decimals

Posted: Tue Dec 22, 2009 10:29 pm
by SFSxOI
Very interesting and nice. Thank You :)

Re: Include - unlimited decimals

Posted: Wed Dec 23, 2009 8:27 am
by Kwai chang caine
Great job 8)
Thanks to sharing

Re: Include - unlimited decimals

Posted: Tue Aug 03, 2010 5:04 pm
by qqqnnn
Thank You

Re: Include - unlimited decimals

Posted: Fri Nov 05, 2021 12:23 pm
by CELTIC88
good work
@STARGÅTE any update ?

Re: Include - unlimited decimals

Posted: Fri Nov 05, 2021 1:00 pm
by STARGÅTE
There is no update regarding this old code.
But I can recommend my new project: Lizard - Script language for symbolic calculations, arbitrary large and precise numbers and more
In this script language you can use decimal numbers with arbitrary precision and magnitude,
and it is easy to use in PB.

Re: Include - unlimited decimals

Posted: Fri Nov 05, 2021 2:16 pm
by CELTIC88
big Thank you are the best :D