note 102789 added to language.types.float

From: Date: Mon, 07 Mar 2011 03:35:16 +0000
Subject: note 102789 added to language.types.float
Groups: php.notes 
Request: Send a blank email to php-notes+get-177603@lists.php.net to get a copy of this message
I found that 00000000 hex was converting to 1.0 decimal. From the Wikipedia article on IEEE-754 floating point: The true significand includes 23 fraction bits to the right of the binary point and an implicit leading bit (to the left of the binary point) with value 1 unless the exponent is stored with all zeros. In hex2float32n, replace: $intnumber=bindec("1".$binint); with if ($exp <> -127) { $intnumber=bindec("1".$binint); }; and then 00000000 works correctly without affecting "normal" numbers. ---- Server IP: 69.147.83.197 Probable Submitter: 173.79.55.208 ---- Manual Page -- http://www.php.net/manual/en/language.types.float.php Edit -- https://master.php.net/note/edit/102789 Del: integrated -- https://master.php.net/note/delete/102789/integrated Del: useless -- https://master.php.net/note/delete/102789/useless Del: bad code -- https://master.php.net/note/delete/102789/bad+code Del: spam -- https://master.php.net/note/delete/102789/spam Del: non-english -- https://master.php.net/note/delete/102789/non-english Del: in docs -- https://master.php.net/note/delete/102789/in+docs Del: other reasons-- https://master.php.net/note/delete/102789 Reject -- https://master.php.net/note/reject/102789 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#177603) next »