php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #35898 round() documentation incorrect
Submitted: 2006-01-04 21:09 UTC Modified: 2006-01-04 22:50 UTC
From: matt at equaliser dot net Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: Linux
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: matt at equaliser dot net
New email:
PHP Version: OS:

 

 [2006-01-04 21:09 UTC] matt at equaliser dot net
Description:
------------
Documentation reads

round -- Rounds a float
Description
float round ( float val [, int precision] )

Returns the rounded value of val to specified precision (number of digits after the decimal point). precision can also be negative or zero (default). 

Should read:

Returns the rounded value of val's floating point representation in memory to specified precision (number of digits after the decimal point). 

WARNING: This function may not return expected results for floating point numbers in memory whose string representation ends in a 5. eg:

round (7.875 , 1);

returns '7.88'

$a = 45;
$b = $a * .175;
round ($b , 1);

May return either '7.88' or '7.87'. 

See http://www.php.net/manual/en/language.types.float.php

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
$


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-04 22:50 UTC] sniper@php.net
There's nothing wrong with round()'s docs. See also 'precision' php.ini setting.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Nov 20 12:00:01 2025 UTC