|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-03-03 04:04 UTC] eugen at iwep dot ab dot ru
Hi all, Please try
<?
$dat=pack ("f", 1.1);
$ar=unpack('fx',$dat);
print 'x='.$ar['x'].'<br>';
?>
Output:
x=1.10000002384
^^^^^^^^^^^^^^^^?????????????? maybe bug with float ?
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 29 09:00:01 2025 UTC |
The optimal approach at solving this problem, would be to use doubles, since in PHP floats are emulated via doubles. <? $dat=pack ("d", 1.1); $ar=unpack('dx',$dat); print 'x='.$ar['x'].'<br>'; ?> correctly will return ["x"]=> float(1.1)