Difference between float, double and real?

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-22-2008
Wander
 
Posts: n/a
Default Difference between float, double and real?

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?
Reply With Quote
  #2 (permalink)  
Old 05-22-2008
Iván Sánchez Ortega
 
Posts: n/a
Default Re: Difference between float, double and real?

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)
Reply With Quote
  #3 (permalink)  
Old 05-22-2008
Wander
 
Posts: n/a
Default Re: Difference between float, double and real?

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?
Reply With Quote
  #4 (permalink)  
Old 05-22-2008
ZeldorBlat
 
Posts: n/a
Default Re: Difference between float, double and real?

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.
Reply With Quote
  #5 (permalink)  
Old 05-22-2008
Iván Sánchez Ortega
 
Posts: n/a
Default Re: Difference between float, double and real?

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

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:23 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0