|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-04-20 07:50 UTC] johannes@php.net
[2013-04-20 07:50 UTC] johannes@php.net
-Status: Open
+Status: Not a bug
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 13 22:00:01 2025 UTC |
Description: ------------ Hi, first some informations: vanilla php 5.4.14 without any changes from your website, and a php 5.4.13 on a linux host. C:\Users\Administrator>php -v PHP 5.4.12 (cli) (built: Feb 19 2013 21:26:17) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies root@verfriemelt:~# php -v PHP 5.4.13-1~dotdeb.1 (cli) (built: Mar 21 2013 08:29:56) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies ------------ i have a number like 8 and add 0.001 while this number reaches 11. i suspected the numbers in between should look like 8.999 and 10.743 but instead i got some like this: 8.9899999999999 and i noticed a gap between some numbers. eg: 8.09 + 0.001 equals 8.090999999999 i suspected a problem with my linux box and tested it with my windows workstation, same result. so i guess its a php internal error. this doest not occur, when i simple add 0.001 to 8.09 so i guess it has something to do with the for() Test script: --------------- <?php for ($i = 8; $i< 11; $i += 0.001) { echo $i . "\n"; } Expected result: ---------------- [...] 8.08 8.081 8.082 8.083 8.084 8.085 8.086 8.087 8.088 8.089 8.09 8.091 8.092 8.093 8.094 8.095 8.096 8.097 8.098 8.099 8.1 [...] Actual result: -------------- 8.08 8.081 8.082 8.083 8.084 8.085 8.086 [...] 8.087 8.088 8.089 8.09 8.0909999999999 8.0919999999999 8.0929999999999 8.0939999999999 8.0949999999999 8.0959999999999 8.0969999999999 8.0979999999999 8.0989999999999 8.0999999999999 8.1009999999999 [...]