Value range of Floats ?

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Andre.

Someone sent me this test code (little modified by me):

Code: Select all

DefType.f 
v=3568464845
y=3447 
x=v/y 
MessageRequester("Calc",StrF(x),0)
What is the exact possible value range of float variables? (Manual says "unlimited".)

Regards
André

*** German PureBasic Support ***
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by geoff.

I don't think this is a range problem.

I think it's a string to float conversion bug for the 3568464845.

Single floats give an accuracy of about 6 decimal digits in the number range 1E-35 to 1e35
(ie 1 followed by 35 zeros at the high end)

Doubles give an accuracy of about 15 decimal digits in the number range 1e-300 to 1e300.

The exact values depend on the implementation used.

On a modern processor with integrated hardware co-processor there is negligible speed penalty in using doubles for all floating point calculations.
Post Reply