Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Determine largest possible float value

0 views
Skip to first unread message

Thomas Mlynarczyk

unread,
Oct 24, 2006, 3:33:37 PM10/24/06
to
Hi,

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


Koncept

unread,
Oct 26, 2006, 11:05:39 AM10/26/06
to
In article <ehlpqn$ttd$01$1...@news.t-online.com>, Thomas Mlynarczyk
<tho...@mlynarczyk-webdesign.de> wrote:

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

Thomas Mlynarczyk

unread,
Oct 26, 2006, 1:43:07 PM10/26/06
to
Also sprach Koncept:

"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


0 new messages