Actually I took a second look and decided that Math.rint() is really
the best rounding mode for my purposes ... I reported this bug in the
GWT issue tracker, however.

On Oct 30, 7:19 pm, Dobes <[EMAIL PROTECTED]> wrote:
> It appears that Math.rint() is not working correctly inside the web
> browser.  I ran the following test in hosted mode and in "web" mode:
>
> StringBuffer sb = new StringBuffer();
> sb.append("4200 * 1.0825 = ").append(4200 * 1.0825).append('\n');
> sb.append("4200 * 0.0825 = ").append(4200 * 0.0825).append('\n');
> sb.append("Math.rint(4200 * 1.0825) = ").append(Math.rint(4200 *
> 1.0825)).append('\n');
> sb.append("Math.rint(4200 * 0.0825) = ").append(Math.rint(4200 *
> 0.0825)).append('\n');
> sb.append("(long)Math.rint(4200 * 1.0825) =
> ").append((long)Math.rint(4200 * 1.0825)).append('\n');
> sb.append("(long)Math.rint(4200 * 0.0825) =
> ").append((long)Math.rint(4200 * 0.0825)).append('\n');
> testResults = sb.toString();
>
> In hosted mode (using the Java libraries) I get the correct output:
>
> 4200 * 1.0825 = 4546.5
> 4200 * 0.0825 = 346.5
> Math.rint(4200 * 1.0825) = 4546.0
> Math.rint(4200 * 0.0825) = 346.0
> (long)Math.rint(4200 * 1.0825) = 4546
> (long)Math.rint(4200 * 0.0825) = 346
>
> In firefox, IE7, and Google Chrome Math.rint() incorrectly rounds up
> as follows:
>
> 4200 * 1.0825 = 4546.5
> 4200 * 0.0825 = 346.5
> Math.rint(4200 * 1.0825) = 4547
> Math.rint(4200 * 0.0825) = 347
> (long)Math.rint(4200 * 1.0825) = 4547
> (long)Math.rint(4200 * 0.0825) = 347
>
> Does anyone have a correct implementation of Math.rint() for GWT
> somewhere that I can use?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to