Simple Math - b4a or java issue

wes58

Active Member
Licensed User
Longtime User
I have tried to do a simple math calculation (in the real application it is not that simple):

Dim l1, l2, l3, l4 As Double
l1 = 0.57
l2 = -0.34
l3 = -0.23
l4 = l1 + l2 + l3
Log("l4 = " & l4)
l4 = NumberFormat(l4, 0, 2)
Log("l4 = " & l4)

The result of the first log is: l4 = -8.326672684688674E-17
The result of the second is: l4 = -0

And I don't like either of the results because both of them should be showing value 0. There is no number -0, is there?

Am I doing something wrong or is it b4a issue or java?
Any suggestions? I wasted so much time before I realized that something like this happened - I would have never expected it.
 
Top