M MDimitris Member Licensed User Aug 25, 2017 #1 Hello, Can someone explain me why power(5,4) return 624.9999999999997 ? I use b4x version 7.30 Thanks
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 Aug 25, 2017 #2 Noone can answer without seeing your code... I guess you are using int, double, long etc wrong or you use NumberFormat wrong. Upvote 0
Noone can answer without seeing your code... I guess you are using int, double, long etc wrong or you use NumberFormat wrong.
M MDimitris Member Licensed User Aug 25, 2017 #3 hi, my code is: dim xx as double xx=power(5,4) .... .... Upvote 0
An Schi Well-Known Member Licensed User Aug 25, 2017 #4 If this is realy all your code, which deals with this - then i don't understand...... Upvote 0
M MDimitris Member Licensed User Aug 25, 2017 #5 this is a test like you test but ... I do not understand... thank you Attachments 2017-08-25.png 47.8 KB · Views: 339 Upvote 0
An Schi Well-Known Member Licensed User Aug 25, 2017 #6 Ok, i'm out Till some experts arrive i suggest you play wirh NumberFormat. Sorry for not being a better help Upvote 0
Ok, i'm out Till some experts arrive i suggest you play wirh NumberFormat. Sorry for not being a better help
stevel05 Expert Licensed User Longtime User Aug 25, 2017 #7 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
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.
An Schi Well-Known Member Licensed User Aug 25, 2017 #8 For the statistic: 625 on galaxy s4 with android 5.0.1 and b4a 7.30 Upvote 0
M MDimitris Member Licensed User Aug 25, 2017 #9 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
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
Erel B4X founder Staff member Licensed User Longtime User Aug 27, 2017 #10 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. Upvote 0
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.
M Mahares Expert Licensed User Longtime User Aug 27, 2017 #11 Erel said: 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. Click to expand... 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
Erel said: 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. Click to expand... 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.
Computersmith64 Well-Known Member Licensed User Longtime User Aug 28, 2017 #12 This might help explain it (or not!) - http://floating-point-gui.de/ - Colin. Upvote 0