php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62809 Arithmetic operations on SplFloat unexpected behavior
Submitted: 2012-08-13 13:56 UTC Modified: 2017-01-10 08:14 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: martinbiard at videotron dot ca Assigned:
Status: Suspended Package: SPL_Types (PECL)
PHP Version: 5.4.5 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: martinbiard at videotron dot ca
New email:
PHP Version: OS:

 

 [2012-08-13 13:56 UTC] martinbiard at videotron dot ca
Description:
------------
Arithmetic operations on SplFloat objects require explicit type cast to (float) primitive type for expected behavior.

Test script:
---------------
$a = 3;
$b = 1.55;
$c = $a + $b;
echo $c . PHP_EOL; // prints 4.55

$d = new \SplFloat(3.00);
$e = new \SplFloat(1.55);
$f = $d + $e;
echo $f . PHP_EOL; // prints 4 (unexpected)

$g = new \SplFloat(3.00);
$h = new \SplFloat(1.55);
$i = (float)$g + (float)$h;
echo $i . PHP_EOL; // prints 4.55

Expected result:
----------------
4.55
4.55
4.55

Actual result:
--------------
4.55
4
4.55

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-10 08:14 UTC] kalle@php.net
-Status: Open +Status: Suspended
 [2017-01-10 08:14 UTC] kalle@php.net
Suspending this report as the extension have not had a release for almost 5 years.  Please revive this if the extension once again shows life
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 02:01:30 2024 UTC