Thursday, December 17, 2009

Re: GWT Random

I apologize, hemodroid, upon further research I was able to replicate
this using the version of nextInt() with no arguments:

public static native int nextInt() /*-{
// "~~" forces the value to a 32 bit integer.
return ~~(Math.floor(Math.random() * 4294967296) - 2147483648);
}-*/;

This code on Google Chrome (at least 4.0.249.43 for Mac) does indeed
generate only even numbers.

On Dec 17, 9:20 am, Brandon Tilley <codemaster...@gmail.com> wrote:
> GWT Random uses the browser's underlying JavaScript math library to
> generate random numbers:
>
>   public static native int nextInt(int upperBound) /*-{
>     // "~~" forces the value to a 32 bit integer.
>     return ~~(Math.floor(Math.random() * upperBound));
>   }-*/;
>
> I ran a quick test of this code in Google Chrome for Mac (4.0.249.43)
> and I received both even and odd numbers. If there really is a
> problem, it should be with Chrome, not GWT.
>
> On Dec 17, 8:08 am, hemodroid <hemodr...@gmail.com> wrote:
>
> > I'd dont know about u, but i noticed that in my Google Chrome browser,
> > GWT Random always generate even numbers.

--

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate