php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29921 Float .25 as opposed to 0.25 calculates to 0
Submitted: 2004-08-31 18:33 UTC Modified: 2004-08-31 19:10 UTC
From: nat at noworrie dot com Assigned:
Status: Not a bug Package: Math related
PHP Version: 5.0.1 OS: FreeBSD 4.8
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: nat at noworrie dot com
New email:
PHP Version: OS:

 

 [2004-08-31 18:33 UTC] nat at noworrie dot com
Description:
------------
Using PHP 5.0.1 as a CGI script.

10 * '.25' should be 2.5 but it equates to 0.

10 * floatval('.25') does equal 2.5.

Does not occur in PHP 5.0.0RC2.

May be a related to Bug # 29547.

Reproduce code:
---------------
$a = '.25';
$b = '0.25';
echo "10 * .25 == ".(10*$a)."\n";
echo "10 * 0.25 == ".(10*$b)."\n";


Expected result:
----------------
10 * .25 == 2.5
10 * 0.25 == 2.5


Actual result:
--------------
10 * .25 == 0
10 * 0.25 == 2.5

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-31 19:10 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

.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC