Bug #70009 [Opn->Nab]: modulus operator error
| From: | requinix@php.net | Date: | Tue, 07 Jul 2015 10:21:45 +0000 |
| Subject: | Bug #70009 [Opn->Nab]: modulus operator error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-194169@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70009&edit=1
ID: 70009
Updated by: requinix@php.net
Reported by: s7sunder at gmail dot com
Summary: modulus operator error
-Status: Open
+Status: Not a bug
Type: Bug
Package: Unknown/Other Function
Operating System: LINUX UBUNTU 14.04
PHP Version: 5.6.11RC1
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2015-07-07 10:21:07] s7sunder at gmail dot com
Description:
------------
Why these 2 values are not returning the true
var_dump((1.005*1000)%5==0); //boolean false
var_dump((1.015*1000)%5==0); //boolean false
Remaining values are correct.
Test script:
---------------
<?php
//These 2 are not returning the expected results
var_dump((1.005*1000)%5==0); //boolean false
var_dump((1.015*1000)%5==0); //boolean false
var_dump((1.005*1000)%5==0); //boolean false
var_dump((1.010*1000)%5==0); //boolean true
var_dump((1.015*1000)%5==0); //boolean false
var_dump((1.020*1000)%5==0); //boolean true
var_dump((1.025*1000)%5==0); //boolean true
var_dump((1.030*1000)%5==0); //boolean true
var_dump((1.035*1000)%5==0); //boolean true
var_dump((1.035*1000)%5==0); //boolean true
var_dump((1.040*1000)%5==0); //boolean true
var_dump((1.045*1000)%5==0); //boolean true
var_dump((1.050*1000)%5==0); //boolean true
var_dump((1.055*1000)%5==0); //boolean true
var_dump((1.060*1000)%5==0); //boolean true
var_dump((1.065*1000)%5==0); //boolean true
var_dump((1.070*1000)%5==0); //boolean true
var_dump((1.075*1000)%5==0); //boolean true
var_dump((1.080*1000)%5==0); //boolean true
var_dump((1.085*1000)%5==0); //boolean true
var_dump((1.090*1000)%5==0); //boolean true
var_dump((1.095*1000)%5==0); //boolean true
var_dump((1.100*1000)%5==0); //boolean true
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70009&edit=1