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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
33 - 11 = ?
Subscribe to this entry?

 
 [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: Mon May 06 07:01:32 2024 UTC