php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77512 Mathematical errors
Submitted: 2019-01-24 10:35 UTC Modified: 2019-01-24 11:19 UTC
From: lea21st at qq dot com Assigned: cmb (profile)
Status: Not a bug Package: *General Issues
PHP Version: 7.1.26 OS: Cenots7.4
Private report: No CVE-ID: None
 [2019-01-24 10:35 UTC] lea21st at qq dot com
Description:
------------
2.333%1==0;  //true
2%1==0;     //true

2.333%1,It should be false,2.333%1 is 0.33300000

Test script:
---------------
var_dump(2%1);
var_dump(2.333%1);

Expected result:
----------------
0
0.333000000000

Actual result:
--------------
0
0

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-01-24 11:19 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2019-01-24 11:19 UTC] cmb@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

From the PHP manual[1]:

| Operands of modulo are converted to integers (by stripping the
| decimal part) before processing. For floating-point modulo, see
| fmod().

[1] <php.net/manual/en/language.operators.arithmetic.php>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 09:01:29 2024 UTC