Bug #70261 [Opn]: Error when comparing floating point

From: Date: Thu, 13 Aug 2015 18:24:13 +0000
Subject: Bug #70261 [Opn]: Error when comparing floating point
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195191@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70261&edit=1

 ID:                 70261
 User updated by:    egdn2004 at gmail dot com
 Reported by:        egdn2004 at gmail dot com
 Summary:            Error when comparing floating point
 Status:             Open
 Type:               Bug
 Package:            Reproducible crash
 Operating System:   All
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Test script:
---------------
<?php
$var1 = 9.22;
$var2 = 9.20;

$var_test = $var2 + 0.02;

if ($var1 > $var_test) {
    echo "WRONG\n";
} else {
    echo "OK\n";
}

if (9.22 > 9.20 + 0.02) {
    echo "WRONG";
} else {
    echo "OK";
}

Expected result:
----------------
OK
OK

Actual result:
--------------
WRONG
WRONG


Previous Comments:
------------------------------------------------------------------------
[2015-08-13 18:13:08] egdn2004 at gmail dot com

Description:
------------
Error when comparing floating point with two decimal places

Test script:
---------------
<?php

if (9.2 > 9.0 + 0.2) {
    echo 'WRONG';
} else {
    echo 'OK';
}

Expected result:
----------------
OK

Actual result:
--------------
WRONG


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=70261&edit=1


Thread (3 messages)

« previous php.bugs (#195191) next »