type casting to float to "ensure reliable comparison" ?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
in a book i am ready now : O'Reilly - Web Database Application with PHP
and MySQL, 2nd ed. by David Lane, Hugh E. Williams

on chapter 9 the author give an example for age validation :
(simplified code, not a direct quote)

$dob = mktime(0,0,0, 5, 3, 1983);

if ((float)$dob > (float)strtotime("-18years"))
    print "....";
    return false;

my question is why the type casting to float ?
after all the return type of both mktime & strtotime is int, why the
need to cast to float?
the authors emphasize this in the explanation section by "We use the
mktime() function to convert the date of birth to a large numeric Unix
timestamp value, and the strtotime() function to discover the timestamp
of exactly 18 ago. *Both are cast to a large floating number to ensure
reliable comparison...*"

thank you for comment's ohh & yes - hope I'm not breaking any copyright
lows :).

Re: type casting to float to "ensure reliable comparison" ?

"maxim vexler <hq4ever (at) 012 (dot) net (dot) il> >" <"maxim vexler
<hq4ever (at) 012 (dot) net (dot) il> wrote in message
Quoted text here. Click to load it

I don't see any need for casting. Anyone?

The author's use of a Unix timestamp to store a birthday makes me suspect
his experience with PHP. It is rather well known that mktime() on PHP-Win32
can't handle dates before 1970. The code would still work, but for a book,
it is a poor example.

Site Timeline