ICU misparses numbers in scientific notation

Description

Deleted Component: formatting

virtual void NumberFormat:arse(const UnicodeString & text, Formattable & result, UErrorCode & status)

described here:

http://icu-project.org/apiref/icu4c/classNumberFormat.html#1e9d508f9ec3311f9ddd6c8d5e600db4

fails to parse numbers from 1E+10 to 1E+18.

Numbers up to 1E+9 and above 1E+19 work.

The reason is that the numbers in the non-working range from 1E+10 to 1E+18 are parsed into an int64 (the smaller ones are parsed into a long, the bigger ones in to a double)and then

double Formattable::getDouble(UErrorCode & status)

http://icu-project.org/apiref/icu4c/classFormattable.html#d8432157817c2d6564352618b8cfd5fd

fails to get the int64 correctly because of a problem in

int64_t DigitList::getInt64()

in the file digitlst.cpp.

Here is a patch which fixes the problem:

The problem occurs because in the original code
“copy” created in this block:

goes out of scope here, therefore the pointer workingNum points to
something not existing anymore and then this pointer is used
in the code which follows:

This has the effect that 0 is returned by int64_t DigitList::getInt64()
when something like "1E+10" is parsed.

And sometimes it even crashes.

The patch above is against libicu 4.4.2 but the problem apparently still exists in 4.6RC2, I checked the source in this tarball:

http://download.icu-project.org/files/icu4c/4.6rc2/icu4c-4_6_rc2-src.tgz

The problem was first reported here:

https://projects.maemo.org/bugzilla/show_bug.cgi?id=206085

PS:

By the way, I noticed that since version 4.4.2, icu seems to be case
sensitive when parsing the exponential symbol, version 4.4.1 could
parse both “3.4e+38” '''and''' “3.4E+38” in en_GB locale, version
4.4.2 parses only “3.4E+38” in en_GB locale. Was this change done on
purpose?

Activity

Show:
TracBot
July 1, 2018, 9:35 AM
Trac Comment 5 by —2016-10-05T23:13:36.787Z

Milestone 4.7.1 deleted

Fixed

Assignee

Andy Heninger

Reporter

TracBot

Components

None

Labels

None

Reviewer

None

Priority

major

Time Needed

None

Fix versions