Page 1 of 1

Why can't I cast this float to int?

Posted: Thu Jul 29, 2004 4:07 am
by tores
Hi.

I divide to numerics and get 33.670033670034
Then I do a ceil() and get 34
But when I try to convert/cast (float) 34 to (int) 34 I get no result...

Is there some hidden overflow or something I'm missing?

Posted: Thu Jul 29, 2004 4:26 am
by feyd
this sure seems to work

Code: Select all

<?php

$foo = 33.670033670034;

var_dump($foo);
echo "\n";
var_dump(ceil($foo));
echo "\n";
var_dump((int)ceil($foo));

?>
outputs

Code: Select all

float(33.670033670034)

float(34)

int(34)

Posted: Thu Jul 29, 2004 4:37 am
by tores
It sure does... After some testing I got it working to... Guess it must have been some variable mismatch or something else that went by undetected :?

Posted: Thu Jul 29, 2004 4:40 am
by feyd
the fun of having E_NOTICE turned off, maybe..

Posted: Thu Jul 29, 2004 5:03 am
by tores
Probably :wink: