Decimal precision

Hello my friends,
I know this topic has been discussed before but I haven’t found a solution yet.
I would like to print all the decimal places of a real number.
I use this method:

Dim i As Integer
Var DeciX, s As String

For i = 0 To 30
  DeciX = DeciX + "#"
Next

s = Format(Valeur, "#." + DeciX)

Return s

My value is Pi : 3.141592653589793238462643383279502884197
And the result is : 3,1415926535897931159979634685442
How to explain that?

Hi Benoit:

Your result is correct. “Valeur” must be a double-precision floating point variable. This has 15 decimal places of precision (at most). This is exactly what you have: 3,141592653589793

If you need higher precision (more correct decimal places), then see the thread at Compiler Explorer and 128 bit math

Thank youuu Mike!
Our computers run in 64 bits now, doesn’t that affect the number of decimal places?

Maybe you can take a look at Einhugur Open source plugins
https://einhugur.com/Html/opensource.html

and it fpPlugin :
https://bitbucket.org/einhugur/fpplugin/src/master/

No. Doubles are doubles regardless of cpu.

1 Like