Issue Details (XML | Word | Printable)

Type: Task Task
Status: Open Open
Priority: Critical Critical
Assignee: jscience-issues
Reporter: hstoerr
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

Real.valueOf(CharSequence) does not work for -0.XXX

Created: 15/Dec/08 05:44 AM   Updated: 31/Jan/11 02:51 AM
Component/s: www
Affects Version/s: current
Fix Version/s: Version 6.0

Time Tracking:
Not Specified


Operating System: All
Platform: All

Issuezilla Id: 116
Participants: hstoerr and jscience-issues

 Description  « Hide

If you give values to Real.valueOf(CharSequence) that start with -0. the answer
is positive. This is since the value before the decimal point is interpreted as
an integer and is checked later for being negative - which does not work if it
is zero. A consequence is that the same error appears at
FloatingPoint.valueOf(CharSequence) as well.

To fix this one can insert the following 3 lines at the start of the function:
if ('-' == chars.charAt(0)) { return valueOf(chars.subSequence(1, chars.length())).opposite(); }

hstoerr added a comment - 23/Dec/08 02:19 PM

This should be a patch instead of an issue, since I included a fix.
Tests to verify the fix are included in issue 120.