php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59597 NumberFormatter::parse() with TYPE_INT64 results in a 32 bit integer
Submitted: 2011-01-30 02:34 UTC Modified: 2012-04-19 18:39 UTC
From: eriksencosta at gmail dot com Assigned: stas (profile)
Status: Closed Package: intl (PECL)
PHP Version: 5.3.2 OS: Ubuntu 10.10
Private report: No CVE-ID: None
 [2011-01-30 02:34 UTC] eriksencosta at gmail dot com
Description:
------------
First, my PHP version is 5.3.5. The bugtracker have this version missing.

I was testing the \NumberFormatter class when I got stuck in a behaviour that I don't know if is by design or not.

Simply, I was expecting a 64 bit integer when calling the parse() method with the $type = \NumberFormatter::TYPE_INT64 as my PHP is 64 bit compiled.

Tried searching the ICU bugtracker but don't found something related (but not sure, I'm not a C programmer): http://bugs.icu-project.org/trac/query?project=ICU4C&summary=~NumberFormat&summary=~int64&order=id&desc=1

Mine intl info:

intl

Internationalization support => enabled
version => 1.1.0
ICU version => 4.2.1

Directive => Local Value => Master Value
intl.default_locale => no value => no value
intl.error_level => 0 => 0


Thanks.

Reproduce code:
---------------
<?php

$formatter = new \NumberFormatter('en', \NumberFormatter::DECIMAL);
$value = $formatter->parse('2147483647', \NumberFormatter::TYPE_INT32);
var_dump($value);

$formatter = new \NumberFormatter('en', \NumberFormatter::DECIMAL);
$value = $formatter->parse('2147483650', \NumberFormatter::TYPE_INT64);
var_dump($value);

Expected result:
----------------
int(2147483647)
int(2147483650)

Actual result:
--------------
int(2147483647)
int(-2147483646)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-19 18:39 UTC] stas@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: stas
 [2012-04-19 18:39 UTC] stas@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Sep 27 17:01:24 2020 UTC