jmoenig / Snap

a visual programming language inspired by Scratch
http://snap.berkeley.edu
GNU Affero General Public License v3.0
1.51k stars 745 forks source link

Display large numbers #1832

Open nathalierun opened 7 years ago

nathalierun commented 7 years ago

Hello everybody,

I have a little project, using a Ramanujan formula, to calculate some decimals of Pi. http://snap.berkeley.edu/snapsource/snap.html#present:Username=nathalierun&ProjectName=2017-08-16-Pi.Ramanujan1 I know that Snap! is able to calculate with large numbers. But I don't know how to access them. How can I print more than 15 decimals ?

Thank you for any help.

brianharvey commented 7 years ago

If you go to File>Libraries, you can select the "infinite precision integer" library. It doesn't quite do what you want; floating point (decimal) values are still limited to 15 significant digits. But it does allow for exact rational arithmetic, and the numerators and denominators are infinite precision. I'm thinking you could build your own long division procedure that would generate a string of digits instead of an actual decimal number. And of course you also have to deal with that √2 somehow.

So, long story short, this library can help but it won't trivially give you high precision decimal values.

nathalierun commented 7 years ago

Le 18/08/2017 à 09:27, Brian Harvey a écrit :

it does allow for exact /rational/ arithmetic, and the numerators and denominators are infinite precision.

I see. Thank you.

So, I have now to create my own long division procedure that would generate a string of digits instead of an actual decimal number. I have to think about it...