note 111205 added to language.types.float

From: Date: Fri, 25 Jan 2013 17:57:05 +0000
Subject: note 111205 added to language.types.float
Groups: php.notes 
Request: Send a blank email to php-notes+get-193390@lists.php.net to get a copy of this message
/** hex2float * (Convert 8 digit hexadecimal value to float (single-precision 32bits) * Accepts 8 digit hexadecimal values in a string * @usage: * hex2float32n("429241f0"); returns -> "73.128784179688" * */ function hex2float($number) { $binfinal = sprintf("%032b",hexdec($number)); $sign = substr($binfinal, 0, 1); $exp = substr($binfinal, 1, 8); $mantissa = "1".substr($binfinal, 9); $mantissa = str_split($mantissa); $exp = bindec($exp)-127; $significand=0; for ($i = 0; $i < 24; $i++) { $significand += (1 / pow(2,$i))*$mantissa[$i]; } return $significand * pow(2,$exp) * ($sign*-2+1); } ---- Server IP: 69.147.83.199 Probable Submitter: 184.74.47.185 ---- Manual Page -- http://php.net/manual/en/language.types.float.php Edit -- https://master.php.net/note/edit/111205 Del: integrated -- https://master.php.net/note/delete/111205/integrated Del: useless -- https://master.php.net/note/delete/111205/useless Del: bad code -- https://master.php.net/note/delete/111205/bad+code Del: spam -- https://master.php.net/note/delete/111205/spam Del: non-english -- https://master.php.net/note/delete/111205/non-english Del: in docs -- https://master.php.net/note/delete/111205/in+docs Del: other reasons-- https://master.php.net/note/delete/111205 Reject -- https://master.php.net/note/reject/111205 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#193390) next »