View Full Version : Arbitrary Precision Calculator
unknown
2007.05.26, 08:50 PM
What do you use to do calculations like some number with 1000 decimal places to the power of another?
I've looked at Calculator.app, irb, bc, dc, java etc.. everything seems nasty
Any nice programs which are capable of this?
Duane
2007.05.26, 10:09 PM
I wrote one a while back for 128 bit integers, but it has to be ported to ppc if you want to use it on that. But floats are tricky, I stopped with integers.
FreakSoftware
2007.05.27, 01:32 AM
You can do it just like you would in 2nd grade. Line em up and multiply digit by digit over and over.
PowerMacX
2007.05.27, 02:34 AM
I haven't used it, but this app claims "1000000 digits" precision:
http://www.haxial.com/products/calculator/
Edit: a macosxhints.com comment pointed to this arbitrary precision calculator:
http://www.isthe.com/chongo/tech/comp/calc/index.html
imikedaman
2007.05.27, 02:46 AM
What do you use to do calculations like some number with 1000 decimal places to the power of another?
Use "bc" in the Terminal. If you need your program to be able to do these calculations, open a new shell and run a command like this:
echo "5 + 5" | bc
That returns the string "10".
EDIT: Oh, I didn't read your whole post. What's wrong with bc? I use it from time to time; it seems nice.
Aressera
2007.05.27, 07:33 AM
You could use java's BigInteger or BigDecimal implementations. They have a large amount of precision (i'm not really sure), but should do the job. But then again, if you have an aversion to java or speed is an issue....
martinsm
2007.05.27, 09:19 AM
I'am using Python longs:
>>> 1919191919191919191919L + 10L**30
1000000001919191919191919191919L
Duane
2007.05.27, 08:07 PM
http://apfp.sourceforge.net/
woot. Gonna put this sucker into my fraction calculator :D
Duane
2007.06.01, 05:07 PM
hey, C# has a type called 'BigDecimal,' goes to 28 decimals or something. worked great for me
Duane
2007.06.03, 06:14 PM
I wrote a bc wrapper for ruby before realizing that for floats, bc uses doubles. Pretty sure, anyhow.
Ahh, never mind me. you just have to set length and scale, which for some reason, my ruby program chokes and dies on.
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.