php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24330 bug in ABS()
Submitted: 2003-06-25 06:53 UTC Modified: 2003-06-25 07:48 UTC
From: vm at color-pro dot com Assigned:
Status: Not a bug Package: *Math Functions
PHP Version: 4.3.1 OS: FreeBSD 4.5
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: vm at color-pro dot com
New email:
PHP Version: OS:

 

 [2003-06-25 06:53 UTC] vm at color-pro dot com
Description:
------------
abs not work corectly with <,> operator

Reproduce code:
---------------
if ( abs(0.97 - 0.98) > 0.01 ) echo bed1;   
if ( abs(0.07 - 0.08) > 0.01 ) echo bed2;

if ( 0.01 > 0.01 ) echo bed3;

Expected result:
----------------
there must nothing here printing !!! 

Actual result:
--------------
bed1 here printing 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-25 07:01 UTC] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Read the section on floats again...
 [2003-06-25 07:15 UTC] vm at color-pro dot com
derick i don't anderstand u.. 
can u tell me why this:
if ( abs(0.97 - 0.98) > 0.01 ) echo bad; 
print bad.. ?
 [2003-06-25 07:22 UTC] derick@php.net
http://nl3.php.net/manual/en/language.types.float.php
read the big warning...
 [2003-06-25 07:42 UTC] vm at color-pro dot com
and what to do??
 [2003-06-25 07:48 UTC] vm at color-pro dot com
i understood :))

$fuzz = 0.000000000001;
if ( abs(0.97+$fuzz - 0.98+$fuzz) > 0.01 ) echo bed1;

works nice :)) 


but what is difference between:
if ( abs(0.97 - 0.98) > 0.01 ) echo bed1; // print bed1
if ( abs(0.07 - 0.08) > 0.01 ) echo bed2; // nothing print

??
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 00:01:28 2024 UTC