php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44803 round()
Submitted: 2008-04-22 23:41 UTC Modified: 2008-04-23 01:00 UTC
From: oguzhanozbay at yahoo dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.2.5 OS: ýss isapi & apache 2.2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: oguzhanozbay at yahoo dot com
New email:
PHP Version: OS:

 

 [2008-04-22 23:41 UTC] oguzhanozbay at yahoo dot com
Description:
------------
How can it be!

Reproduce code:
---------------
echo round(60000000*10.5);

output 6.3E+8 !!!

echo round(60000000*(10.5));

output 6.3E+8 !!!

echo round(60000000*(10.5),2);

output 6.3E+8 !!!

echo round(70000000*(10.5));

output 7.35E+8 !!!

echo round(70000000*(11.5),2);

output 805000000 => true


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-23 00:47 UTC] felipe@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://docs.sun.com/source/806-3568/ncg_goldberg.html
 
Thank you for your interest in PHP.


 [2008-04-23 01:00 UTC] oguzhanozbay at yahoo dot com
; The number of significant digits displayed in floating point numbers.
precision    =  14

This my php.ini precision config.

I make it 30 (and resart server) but nothing changed.

same server, same config ->

echo 60000000*(10.5);

output 6.3E+8

echo 6000000000000*10;

output 60000000000000

How can "60000000*(10.5)" need much precision than "6000000000000*10"?
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 13:01:28 2025 UTC