php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38548 intval rounds to nearest int
Submitted: 2006-08-22 17:25 UTC Modified: 2006-08-22 17:52 UTC
From: tstarling at wikimedia dot org Assigned:
Status: Not a bug Package: Math related
PHP Version: 4.4.4 OS: Linux
Private report: No CVE-ID: None
 [2006-08-22 17:25 UTC] tstarling at wikimedia dot org
Description:
------------
We have a report on http://bugzilla.wikimedia.org/show_bug.cgi?id=7013 that in PHP 4.4.3 on linux, integer conversion rounds to the nearest integer. This is a change from the previous behaviour, according to the manual and in previous versions of PHP, integer conversion rounds down. I don't see anything about this in the changelog, so I'm assuming the problem persists in 4.4.4. 

Reproduce code:
---------------
intval(0.99)

Expected result:
----------------
0

Actual result:
--------------
1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-22 17:50 UTC] tony2001@php.net
# php -r 'var_dump(intval(0.9));'
int(0)
# php -v
PHP 4.4.5-dev (cli) (built: Aug 22 2006 21:48:33) (DEBUG)

Same result with 4.4.4, 4.4.3 and others.
Obviously such change could not happen, 'cause it would break lots of tests.

 [2006-08-22 17:51 UTC] tstarling at wikimedia dot org
I couldn't confirm this personally, I tried a new build of 4.4.3 and 4.4.4 on linux, but didn't see the bug on either. Perhaps someone here has an idea about how to reproduce it?
 [2006-08-22 17:52 UTC] tony2001@php.net
>Perhaps someone here has an idea about how to reproduce it?
I guess you should ask the person who originally reported it.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Feb 25 10:01:23 2020 UTC