|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80840 convert to int
Submitted: 2021-03-06 05:00 UTC Modified: 2021-03-06 07:21 UTC
From: reza dot cyber at gmail dot com Assigned:
Status: Not a bug Package: Math related
PHP Version: 7.3.27 OS: all
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
46 - 38 = ?
Subscribe to this entry?

 [2021-03-06 05:00 UTC] reza dot cyber at gmail dot com
Hi. I wrote these lines for the PHP 7.3.5

these codes must return 13495 but return 13494.
I try with the intval function and the result is the same as before.
but when I use the round function it returns the correct answer.

I tested by any PHP version in Linux, Windows, and other online PHP testers.


Test script:
$no = 134.95;
$number = (int)($no*100);
echo $number;//print 13494

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-03-06 07:21 UTC]
-Status: Open +Status: Not a bug
 [2021-03-06 07:21 UTC]
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:

Thank you for your interest in PHP.

> but when I use the round function it returns the correct answer.
Using round() is the solution.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 27 00:01:31 2024 UTC