Android Question Problem with Power function

MDimitris

Member
Licensed User
Hello,
Can someone explain me why
power(5,4) return 624.9999999999997 ?

I use b4x version 7.30
Thanks
 

An Schi

Well-Known Member
Licensed User
Noone can answer without seeing your code...
I guess you are using int, double, long etc wrong or you use NumberFormat wrong.
 
Upvote 0

An Schi

Well-Known Member
Licensed User
If this is realy all your code, which deals with this - then i don't understand......

powertest.png
 
Upvote 0

An Schi

Well-Known Member
Licensed User
:confused::confused:
Ok, i'm out :(
Till some experts arrive i suggest you play wirh NumberFormat.
Sorry for not being a better help ;)
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
It sounds like it may be a device specific result.

What device are you running it on? Do you have a different one to try.

Gives 625 on both Bluestacks and my Sony Xperia.
 
Upvote 0

MDimitris

Member
Licensed User
hello,
You are right. With an Alcatel device (android 6.0.1) is correct 625, with Alcatel (android 2.3.6) correct 625 but with another device Turbox model s (android 4.4.4) return 624.9999997
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Never show double values without using NumberFormat (or the equivalent smart string modifier). NumberFormat will take care of rounding the value based on the required number of decimals.
But this does not tell us why the answer is correct 625 on many devices without invoking the numberformat or smart string, but not on others.
 
Upvote 0
Top