php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44890 converting some doubles to strings yields trailing colon
Submitted: 2008-05-02 09:59 UTC Modified: 2008-05-08 05:51 UTC
From: mr-russ at pws dot com dot au Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.2CVS-2008-05-02 (snap) OS: Ubuntu Linux 8.04
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: mr-russ at pws dot com dot au
New email:
PHP Version: OS:

 

 [2008-05-02 09:59 UTC] mr-russ at pws dot com dot au
Description:
------------
I expect any number, divided by 10 times itself, then converted to a string, to yield "0.1"

In this release, sometimes I get "0.0:" (yes, that's 0.0 with a trailing colon character)

I have tested on i386 and amd64.  amd64 behaves as expected.  i386 gives the invalid result.

Original bug report by Brett Kiefer on Ubuntu Launchpad: https://bugs.launchpad.net/ubuntu/+source/php5/+bug/218891


Reproduce code:
---------------
<?php
        for ($d = 0.10; $d < 1; $d = $d + 0.1) print $d * 10 . " " . ($d / ($d * 10)) . "\n";
?>

Expected result:
----------------
1 0.1
2 0.1
3 0.1
4 0.1
5 0.1
6 0.1
7 0.1
8 0.1
9 0.1
10 0.1

Actual result:
--------------
1 0.1
2 0.1
3 0.1
4 0.1
5 0.1
6 0.0:
7 0.0:
8 0.1
9 0.0:
10 0.1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-06 11:15 UTC] kalle@php.net
Im not able to reproduce this on Windows (XP SP2) using an i386 processor.

Have you tried to reproduce this on other systems to check that its not a bug related to your current OS?
 [2008-05-08 05:51 UTC] mr-russ at pws dot com dot au
I am now under the impression it's a bug with my current operating system. I installed the same snapshot onto an i386 Centos 5.1 box and did not have any problems with the output.

I should have thought to test on more systems than I did.  Sorry for the noise.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Apr 01 19:01:31 2025 UTC