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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: lea21st at qq dot com
New email:
PHP Version: OS:

 

 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Mon May 06 05:01:31 2024 UTC