php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1704 Hexnumber becomes floatingpoint
Submitted: 1999-07-13 12:04 UTC Modified: 1999-07-15 12:09 UTC
From: zznyyd at diku dot dk Assigned:
Status: Closed Package: Other
PHP Version: 3.0.11 OS: Linux 2.2.10
Private report: No CVE-ID: None
 [1999-07-13 12:04 UTC] zznyyd at diku dot dk
This little simple script should demonstrate the
problem. Instead of an integer number it outputs
1.9999990463257.

<?php
  $mask = 0xFFFFF800;
  echo $mask;
?>

PHP was compiled as an Apache module.
I currently have no php3.ini file.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-07-14 03:44 UTC] danny at cvs dot php dot net
convert_to_long in operators.c depends on strtol(), not on strtoul().

 [1999-07-15 12:09 UTC] sas at cvs dot php dot net
This effect can be seen when you use integers which need more than 31 bits to be represented.

In this case the number doesn't fit into a signed long int, so that strtol() returns ERANGE. Therefore the routine automatically uses strtod(), so that you get a float (double). Unfortunately, strtod() is not capable of handling various prefixes to denote different bases, so that you end up with this strange number.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 22:01:29 2024 UTC