Jump to content

Strange Float to Int Conversion With 1


zhoppy

Recommended Posts

Hey guys,

 

I'm having trouble with float(1) converting to int(0) Quick sample code below. Anyone have any ideas?

 

Thanks!

-Zac

 

$a = 7.1;
$i = (($a-7) * 10);
//var_dump($i);
var_dump((int)$i);

$a = 7.1:

Output: int(0)

Expected: int(1)

$a = 7.2:

Output: int(2)

Expected: int(2)

Link to comment
https://forums.phpfreaks.com/topic/79494-strange-float-to-int-conversion-with-1/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.