More precision than a float number

Hi, i need to add more digits here (more than the float precision). How can i do?
image

Does i have to do a long division manually ? (with string?)

When i enable bignums, it return 351/17...

Does i have to use JS ?

if you have an answer, how many digits it support.

Javascript will return the same thing as vanilla snap (no bignums), because snap uses the javascript division operator.

I know bignums should be the answer, but I'm not entirely sure how to convert that to it's computed form.


The question I have is, why do you need more precision?

listing digits of pi

i found this about number type here

(double precision 64bit)
image

Then yes, you need to do the division by hand. Floating point (scientific notation) isn't going to be helpful. I expect you can find libraries for extended-precision computation, but if you're serious about pi, you're aiming for thousands of digits, not just 20 digits instead of 10.

:pensive:
i'm disapointed...

My understanding is that nobody implements infinite-precision real numbers (analogous to infinite-precision integers) because even simple computations such as 1÷3 or 1÷10 require infinitely many bits to get a precise answer.

Pretty sure i'm not the only one on earth who need this...

1st step: I will start with addition

Well, as I said, maybe you can find an existing library.

This is what I get when using decimal.js.

To load the library, I used this.

so 18 digits with decimal if i assume all digits are good

15 digits (or 14 if the last one is an error) with floating point

Thanks for the test

untitled script pic (60)

JS - toFixed@SchemeNumbers.js

thk, i will test it this evening

Wow! I learn something every day.

adding 2 very big positive numbers
(i will test with negative numbers soon. ex:5.1 + -4.222 + 3.669999)

how it work:

  1. normalize the numbers
  2. found the numbers of digits after the dot
  3. add the digits after the dot of all numbers
  4. find the remember
  5. add the digits before the dot os all numbers
  6. extract the right part of the final number (after the dot)
  7. extract the left part of the final number (before the dot) and add the remember
  8. assemble the final digit

An example:
1.1 + 22.22 + 333.999

  1. Normalization
    what is normalization (i invent this...):
    1.1 + 22.22 + 333.999
    become
    001.100 + 022.220 + 333.999
    (same amount of digits before and after for all numbers

  2. number of digits after the dot: 3

  3. add the digits after the dot of all numbers
    100 + 220 + 999 = 1319

  4. find the remember
    at step 2 : number of digits = 3
    i discard last 3 digits of 1319: remmber = 1

  5. add the digits before the dot os all numbers
    001 + 022 + 333 = 356

  6. extract the right part of the final number (after the dot)
    at step 2 : number of digits = 3
    at step 3 : 1319 (last 3 digits) : 319

  7. extract the left part of the final number (before the dot) and add the remember
    at step 4 : remember = 1
    at step 5 : sum = 356
    356 + 1 = 357

  8. assemble the final digit
    357.319

i will try to modify it to add positive and negavive numbers

like : 1.3 + -2.25