php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #36849 hex to float request
Submitted: 2006-03-24 21:17 UTC Modified: 2015-01-09 00:15 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: esri at godseyfamily dot com Assigned: ajf (profile)
Status: Closed Package: *General Issues
PHP Version: 5.1.2 OS: Liinux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: esri at godseyfamily dot com
New email:
PHP Version: OS:

 

 [2006-03-24 21:17 UTC] esri at godseyfamily dot com
Description:
------------
Would simply like to input a hex value and get the float of it back.  The settype of course does not work, or any kind of casting.  A function that parses the binary string introduces a huge amount of overhead when I do 1024 of these values in a row.  I would think that any programming language would have this basic capability.  I'm getting raw data, and a data type that it needs to be converted to.

I checked and didn't see this requested, though I'm sure it has been.



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-28 00:24 UTC] esri at godseyfamily dot com
$num = 0x3F800000;
   printf("%f",$num);

I would expect a return value of:
1.00000

What I am getting is the integer value:
1065353216.000000
 [2006-03-28 00:27 UTC] tony2001@php.net
>What I am getting is the integer value

And the reason is:

#php -r 'echo 0x3f800000;'
1065353216
 [2006-03-28 01:15 UTC] esri at godseyfamily dot com
That does not change my request for a feature.  There is no way of converting to type float or double from a raw form.  This is what I'm asking for.

0x3F800000 should be able to be converted to 1.000000

This is a feature request, as indicated in the Category.
 [2015-01-09 00:15 UTC] ajf@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: ajf
 [2015-01-09 00:15 UTC] ajf@php.net
Use unpack().
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Aug 02 12:00:03 2025 UTC