Well that behavior is normal when working with floats / doubles, thats not
GWT nor browser related. Computers simply can not represent all floating
point numbers accurately internally. See: http://floating-point-gui.de
So your solutions are:
- Use NumberFormat / Math.round to display the
Javascript has some serious problems when working with floating numbers.
Like if you enter the following into a javascript in any browser : 7.3 - 7
These will all give the result : 0.2998
This problems is also visible in GWT :
int test = 7;
double dTest = 7.3;
double result =
Try BigDecimal if you need precision.
/Stefan
Den tisdag 12 januari 2016 kl. 12:28:31 UTC+1 skrev Frank:
>
> Javascript has some serious problems when working with floating numbers.
>
> Like if you enter the following into a javascript in any browser : 7.3 - 7
> These will all give the result :
Hi
Javascript has some serious problems when working with floating numbers.
>
Javascript has no serious problems when working with floating numbers
> Like if you enter the following into a javascript in any browser : 7.3 - 7
>
There is not such number 7.3 in floating point.
> These will
Google the general question of why you should never use binary floating
point (double or float) for currency calculations.
e.g.:
http://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency
On Tuesday, January 12, 2016 at 3:28:31 AM UTC-8, Frank wrote:
>
>