note 61290 modified in function.intval by thiago
| From: | thiago@php.net | Date: | Thu, 14 Aug 2008 13:11:44 +0000 |
| Subject: | note 61290 modified in function.intval by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-143493@lists.php.net to get a copy of this message | ||
intval() returns maxint on number_in_string, if the result would be bigger than it. But for float
returns the signed 32 bit integer with the "same" value:
<?php
$num=-1000;
print($num."\n");
$i_str=sprintf("%u",$num);
print($i_str."\n");
$i1=intval($i_str);
print($i1."\n");
$i2=intval(floatval($i_str));
print($i2."\n");
?>
prints:
-1000
4294966296
2147483647
-1000
--was--
intval() returns maxint on number_in_string, if the result would be bigger than it. But for float
returns the signed 32 bit integer with the "same" value:
<?
$num=-1000;
print($num."\n");
$i_str=sprintf("%u",$num);
print($i_str."\n");
$i1=intval($i_str);
print($i1."\n");
$i2=intval(floatval($i_str));
print($i2."\n");
?>
prints:
-1000
4294966296
2147483647
-1000
http://php.net/manual/en/function.intval.php