Include - unlimited decimals

Share your advanced PureBasic knowledge/code with the community.
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Include - unlimited decimals

Post 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
Last edited by STARGÅTE on Sat Sep 04, 2010 7:38 pm, edited 1 time in total.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Include - unlimited decimals

Post by Fred »

very interesting !
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: Include - unlimited decimals

Post by Michael Vogel »

Nice, looks a little bit like an advanced version of VNF :wink:

Michael
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Re: Include - unlimited decimals

Post by SFSxOI »

Very interesting and nice. Thank You :)
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Include - unlimited decimals

Post by Kwai chang caine »

Great job 8)
Thanks to sharing
ImageThe happiness is a road...
Not a destination
qqqnnn
User
User
Posts: 22
Joined: Mon Jan 11, 2010 7:45 pm

Re: Include - unlimited decimals

Post by qqqnnn »

Thank You
User avatar
CELTIC88
Enthusiast
Enthusiast
Posts: 154
Joined: Thu Sep 17, 2015 3:39 pm

Re: Include - unlimited decimals

Post by CELTIC88 »

good work
@STARGÅTE any update ?
interested in Cybersecurity..
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Include - unlimited decimals

Post 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.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
CELTIC88
Enthusiast
Enthusiast
Posts: 154
Joined: Thu Sep 17, 2015 3:39 pm

Re: Include - unlimited decimals

Post by CELTIC88 »

big Thank you are the best :D
interested in Cybersecurity..
Post Reply