php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45854 intval returns a negative number
Submitted: 2008-08-18 15:53 UTC Modified: 2008-08-18 22:23 UTC
From: olivarra1 at hotmail dot com Assigned: pajoye (profile)
Status: Not a bug Package: Math related
PHP Version: 5.2CVS, 5.3CVS, 6CVS (2008-08-18) OS: win32 only
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: olivarra1 at hotmail dot com
New email:
PHP Version: OS:

 

 [2008-08-18 15:53 UTC] olivarra1 at hotmail dot com
Description:
------------
For too big numbers, intval returns a negative value

Reproduce code:
---------------
<?php
  $a = 25 * pow(1.5, 50);
  echo $a."<br>";
  echo intval($a)."<br>";

  echo "<br>";

  $a = 10 * pow(1.5, 60);
  echo $a."<br>";
  echo intval($a)."<br>";
?>

Expected result:
----------------
15940537505.4
15940537505

367684687169
367684687169

Actual result:
--------------
15940537505.4
-1239331679

367684687169
-1682500287

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-18 15:56 UTC] olivarra1 at hotmail dot com
version was 5.2.1, not 5.2CVS-2008-08-18 (CVS)
 [2008-08-18 18:13 UTC] jani@php.net
Nevermind, happens within all branches, but only with windows.
 [2008-08-18 22:00 UTC] olivarra1 at hotmail dot com
I've tried 5.2.7-dev, but it gives me the same result.

And what does "nevermind" mean? It's a bug, and it have to be solved.
If we say nevermind to all of bugs we won't develop.

Mhh, maybe it's a windows bug, not a php bug?

thanks,
olivarra1
 [2008-08-18 22:23 UTC] pajoye@php.net
> Mhh, maybe it's a windows bug, not a php bug?

It is not a windows bug, that's a sure thing.

> Expected result:
> ----------------
> 15940537505.4
> 15940537505

That can't work, php does not support large integer. It may happen than a 64 system (say compiled on a linux 64 or win64) gives this result, but not a windows 32bits build.

There is already a request for large integer support > bogus.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 05:01:29 2024 UTC