Here is the simplest code to reproduce the problem:
Long number = 6920835985627925859L ;
logger.severe("Original " + number);
logger.severe("From renderer: " +
LongRenderer.instance().render(number));
logger.severe("From parser: " +
LongParser.instance().parse(LongRenderer.instance().render(number)));
Output:
Thu Feb 17 10:20:45 CST 2011
SEVERE: Original 6920835985627925859
Thu Feb 17 10:20:45 CST 2011
SEVERE: From renderer: 6,920,835,985,627,925,859
Thu Feb 17 10:20:45 CST 2011
SEVERE: From parser: 6920835985627925504
---------------------------------------------------
Eric Andresen
On Wed, Feb 16, 2011 at 4:11 PM, Eric Andresen <[email protected]> wrote:
>
> I have an editor that uses a ValueBoxBase<Long> to store a very large number.
> The box is read-only, but it my number gets changed between setValue() and
> getValue().
> Basically, when I set value 6920835985627925836 and then immediately get the
> value, it returns 6920835985627925504 .
> The value shows up properly in the editor itself, but when getValue is
> called, the wrong value comes back.
> I think the problem is in LongParser
> (http://google-web-toolkit.googlecode.com/svn/trunk/user/src/com/google/gwt/text/client/LongParser.java):
>
> public Long parse(CharSequence object) throws ParseException {
> if ("".equals(object.toString())) {
> return null;
> }
> try {
> return (long) NumberFormat.getDecimalFormat().parse(object.toString());
> } catch (NumberFormatException e) {
> throw new ParseException(e.getMessage(), 0);
> }
> }
>
> In this case, parse returns a double, which is then cast to a long. I think
> this is chopping a couple bits of precision off of my Long, causing the
> mutation.
> Can anyone verify if this is correct or not, and if there is an Editor widget
> that can support the full range on a Long ? (This is in GWT 2.2)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.