Arbitrary Precision Calculator

Sage
Posts: 1,403
Joined: 2005.07
Post: #1
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?

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #2
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.

It's not magic, it's Ruby.
Quote this message in a reply
⌘-R in Chief
Posts: 1,253
Joined: 2002.05
Post: #3
You can do it just like you would in 2nd grade. Line em up and multiply digit by digit over and over.
Quote this message in a reply
Moderator
Posts: 771
Joined: 2003.04
Post: #4
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
Quote this message in a reply
Member
Posts: 161
Joined: 2005.07
Post: #5
unknown Wrote: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:
Code:
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.
Quote this message in a reply
Apprentice
Posts: 19
Joined: 2007.03
Post: #6
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....
Quote this message in a reply
Apprentice
Posts: 13
Joined: 2006.10
Post: #7
I'am using Python longs:
Code:
>>> 1919191919191919191919L + 10L**30
1000000001919191919191919191919L
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #8
http://apfp.sourceforge.net/

woot. Gonna put this sucker into my fraction calculator Grin

It's not magic, it's Ruby.
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #9
hey, C# has a type called 'BigDecimal,' goes to 28 decimals or something. worked great for me

It's not magic, it's Ruby.
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #10
I wrote a bc wrapper for ruby before realizing that for floats, bc uses doubles. Pretty sure, anyhow.

[edit]Ahh, never mind me. you just have to set length and scale, which for some reason, my ruby program chokes and dies on.[/edit]

It's not magic, it's Ruby.
Quote this message in a reply
Post Reply