This is a discussion on Difference between float, double and real? within the PHP Language forums, part of the PHP Programming Forums category; currently there are those functions is_float, is_double and is_real, which do exactly the same as far as i can see ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
currently there are those functions is_float, is_double and is_real,
which do exactly the same as far as i can see what surprises me is that $a = (float/double/real) 1; all work, while with settype() only float and double work, and 'real' not. now im wondering, is there any difference between those? and if not, will they all keep existing in php6? or will php continue with only one of them? |
|
|||
|
Wander wrote:
> what surprises me is that $a = (float/double/real) 1; [...] > now im wondering, is there any difference between those? The amount of memory they need. -- ---------------------------------- Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org- "Las religiones, como las luciérnagas, necesitan de oscuridad para brillar" (Arthur Schopenhauer) |
|
|||
|
On May 22, 5:12 pm, Iván Sánchez Ortega <ivansanchez-...@rroba-
escomposlinux.-.punto.-.org> wrote: > The amount of memory they need. thanks for your quick response, could you tell me which of the 3 takes the most memory, and which of them needs the least? |
|
|||
|
On May 22, 11:07 am, Wander <SIMS...@gmail.com> wrote:
> currently there are those functions is_float, is_double and is_real, > which do exactly the same as far as i can see > what surprises me is that $a = (float/double/real) 1; all work, while > with settype() only float and double work, and 'real' not. > now im wondering, is there any difference between those? > > and if not, will they all keep existing in php6? or will php continue > with only one of them? They're all the same. According to the manual, both is_real() and is_double() are simply aliases for is_float(). Also, according to the manual, the "type" parameter to settype() takes "float" since PHP 4.2.0 as the "double" variant was deprecated. |
|
|||
|
Wander wrote:
> On May 22, 5:12 pm, Iván Sánchez Ortega <ivansanchez-...@rroba- > escomposlinux.-.punto.-.org> wrote: >> The amount of memory they need. > > thanks for your quick response, could you tell me which of the 3 takes > the most memory, and which of them needs the least? It really depends on your platform and the configuration of your interpreter/compiler, but the most common scenario is that floats are single-precision 32-bit IEEE 754 floating numbers; reals are an alias for doubles; and doubles are double-precision 64-bit IEEE 754 floating numbers. I suggest you to drop by http://en.wikipedia.org/wiki/IEEE_754-1985 in order to learn a bit more. And, of course, you've earned yourself a RTFM for not reading this: http://php.net/language.types.float "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 (the 64 bit IEEE format)." Cheers, -- ---------------------------------- Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org- Proudly running Debian Linux with 2.6.24-1-amd64 kernel, KDE 3.5.9, and PHP 5.2.6-1 generating this signature. Uptime: 21:49:42 up 22 days, 1:10, 3 users, load average: 1.04, 0.87, 0.67 |
![]() |
| Thread Tools | |
| Display Modes | |
|
|