php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35327 inconsistent ROUND
Submitted: 2005-11-22 11:55 UTC Modified: 2005-11-22 12:22 UTC
From: pb at tdcspace dot dk Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.4.1 OS: w98
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: pb at tdcspace dot dk
New email:
PHP Version: OS:

 

 [2005-11-22 11:55 UTC] pb at tdcspace dot dk
Description:
------------
This is not directly a dedicated bug - but i will report the behaviour anyway.

The ROUND produce no decimals when whole numbers...

Syntax: ROUND(float, decimals)

so...

ROUND(1.345, 2) = "1.35" (OK)

but...

ROUND(1.000, 2) = "1" (we must to add ".00" to get "1.00")

This is somewhat annoying if You want to produce a list
with the same number of decimals - You must after a ROUND test on the output and eventually add a "." and "0" 's.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-22 11:58 UTC] johannes@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

round() returns a float value, use nnumber_fomat or 
[s]printf to format it... 
 [2005-11-22 12:02 UTC] derick@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

Use sprintf(".%2f", 1.000) instead...
 [2005-11-22 12:22 UTC] pb at tdcspace dot dk
Thak You very mucha - I really appreciate.. 

ROUND might then be best suited in fomulas and not output
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 05:01:33 2025 UTC