note 110167 added to function.hexdec

From: Date: Tue, 25 Sep 2012 18:22:17 +0000
Subject: note 110167 added to function.hexdec
Groups: php.notes 
Request: Send a blank email to php-notes+get-191016@lists.php.net to get a copy of this message
//-------------------------------------------------------------// //---This function converts from HEX to 32bit IEEE 754 Float---// //-------------------------------------------------------------// //I think it is usefull and it´s missing in php function hex2float($number) { $bin = hexdec($number); $sign=($bin & 0x80000000)>>31; $exp = (($bin & 0x7F800000)>>23)-127; $coma = ($bin & 0x7FFFFF)>>(23-$exp); $result=$coma | (0x1<<$exp); if($sign==1) {$result = $result*(-1);} return $result; } //--------------usage---------------// // number $a = hex2float(string $b); //-------------example--------------// echo hex2float("4405c000"); //output -> 535 ---- Server IP: 69.147.83.199 Probable Submitter: 200.16.125.83 ---- Manual Page -- http://www.php.net/manual/en/function.hexdec.php Edit -- https://master.php.net/note/edit/110167 Del: integrated -- https://master.php.net/note/delete/110167/integrated Del: useless -- https://master.php.net/note/delete/110167/useless Del: bad code -- https://master.php.net/note/delete/110167/bad+code Del: spam -- https://master.php.net/note/delete/110167/spam Del: non-english -- https://master.php.net/note/delete/110167/non-english Del: in docs -- https://master.php.net/note/delete/110167/in+docs Del: other reasons-- https://master.php.net/note/delete/110167 Reject -- https://master.php.net/note/reject/110167 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#191016) next »