Edit report at https://bugs.php.net/bug.php?id=55368&edit=1
ID: 55368 Comment by: good821 at 126 dot com Reported by: ygautheron at absystech dot fr Summary: ini_set('precision',16) is affecting a simple math result Status: Bogus Type: Bug Package: *Math Functions Operating System: Linux Gentoo (2.6.38-gentoo-r6) PHP Version: 5.3.6 Block user comment: N Private report: N New Comment: http://www.officialoaklandraiders.com/marcus-allen-jersey-c-11_26.html Marcus Allen Throwback Jersey http://www.officialoaklandraiders.com/michael-huff-jersey-c-11_31.html Michael Huff Jersey http://www.officialoaklandraiders.com/richard-seymour-jersey-c-11_20.html Richard Seymour Jersey Previous Comments: ------------------------------------------------------------------------ [2011-08-29 08:08:40] good821 at 126 dot com http://www.officialoaklandraiders.com/kenny-stabler-jersey-c-11_13.html Kenny Stabler Throwback Jersey http://www.officialoaklandraiders.com/louis-murphy-jersey-c-11_14.html Louis Murphy Jersey http://www.officialoaklandraiders.com/lyle-alzado-jersey-c-11_36.html Lyle Alzado Throwback Jersey ------------------------------------------------------------------------ [2011-08-08 09:21:59] cataphr...@php.net Floating point values have a limited precision. Hence a value might not have the same string representation after any processing. That also includes writing a floating point value in your script and directly printing it without any mathematical operations. If you would like to know more about "floats" and what IEEE 754 is, read this: http://www.floating-point-gui.de/ Thank you for your interest in PHP. Expected. ------------------------------------------------------------------------ [2011-08-05 08:47:48] ygautheron at absystech dot fr Ok, well i assume the only patch is var_dump(round(1.196-1,3)*100); I think it's buggy, but maybe there is no C solution to add in the PHP source ? ------------------------------------------------------------------------ [2011-08-05 08:40:09] jeremie dot gw at gmail dot com I don't think it is a php bug. I have the same result with C code. Source : -------- #include "stdio.h" int main(){ double a; a=(1.196-1)*100; printf("Result=%.16f\n",a); return 0; } Result : -------- 19.5999999999999943 Architecture : -------------- Ubuntu 10.04 x86 Linux 2.6.32-33-generic #71-Ubuntu SMP Wed Jul 20 17:30:40 UTC 2011 i686 GNU/Linux gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ------------------------------------------------------------------------ [2011-08-05 08:29:07] ygautheron at absystech dot fr Just noticed that i we try 0.196*100 it works good too. The problem seems to come from the substract ? ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=55368 -- Edit this bug report at https://bugs.php.net/bug.php?id=55368&edit=1