ID:               26702
 Updated by:       [EMAIL PROTECTED]
 Reported By:      bugs dot php dot net at zetafleet dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: Win32; Cygwin x86
 PHP Version:      4.3.3
 New Comment:

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

The problem here is that bin2hey returns a string without the '0x' to
identify a hex number. Hence the string is interpreted as a decimal
number (if possible) when compared to any number. 

To demonstrate:
$ php -r 'var_dump(("0x".bin2hex("D")) == 0x44);'
bool(true)


Previous Comments:
------------------------------------------------------------------------

[2003-12-22 23:24:49] bugs dot php dot net at zetafleet dot com

Description:
------------
This is complicated, so I'll try explaining as best I can.

There is a binary file. The first byte is 0x44. Doing a comparison (==)
to 0x2C returns "TRUE" because 44 is the decimal for 0x2C. The decimal
value of 0x44 is 68. This should return "FALSE" but does not.

Reproduce code:
---------------
(bin2hex("D") == 0x2C) RETURNS TRUE;  SHOULD RETURN FALSE;
(bin2hex("D") == 0x44) RETURNS FALSE; SHOULD RETURN TRUE;
(bin2hex("D") == 44)   RETURNS TRUE;  SHOULD RETURN TRUE;

Expected result:
----------------
print(bin2hex("D") == 0x2C) //prints nothing
print(bin2hex("D") == 0x44) //prints '1'
print(bin2hex("D") == 44)   //prints '1'

Actual result:
--------------
print(bin2hex("D") == 0x2C) //prints '1'
print(bin2hex("D") == 0x44) //prints nothing
print(bin2hex("D") == 44)   //prints '1'


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


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

Reply via email to