I'm looking for a way to determine the largest possible (finite) value a
float variable can have on the platform where the script is running. There
seems to be no function or predefined constant (like PHP_INT_MAX for
integers). I was thinking maybe I could pack() some test data and unpack()
the first x bits of it as float, but I'm not sure if this would work.
Any ideas?
Greetings,
Thomas
The docs say the following (Ch11. Types "Floating point numbers"):
"The size of a float is platform-dependent, although a maximum of
~1.8e308 with a precision of roughly 14 decimal digits is a common
value (that's 64 bit IEEE format)."
Hope this helps you somewhat.
--
Koncept <<
"The snake that cannot shed its skin perishes. So do the spirits who are
prevented from changing their opinions; they cease to be a spirit." -Nietzsche
"The size of a float is platform-dependent, although a maximum of
> ~1.8e308 with a precision of roughly 14 decimal digits is a common
> value (that's 64 bit IEEE format)."
> Hope this helps you somewhat.
Sorry - not quite. I was actually looking for a piece of code which finds
out how a float is stored (mantissa and exponent size) on a given system, so
I can know the largest finite value that would fit in a float on that
system. Something like PHP_INT_MAX but for floats.
Greetings,
Thomas