B4R Question B4R Abs()

giggetto71

Active Member
Licensed User
Longtime User
Hi,
maybe I am wrong, but it seems to me that Abs (at least when used on a ESP8266) return the int part of the number instead of the absolute value..
example: Abs (-1.23) should return 1.23 and Abs(1.23) should return 1.23 while it return 1..
Am I missing somegthing ?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Looks like a bug or an unexpected difference between the standard Arduino implementation and ESP8266 implementation: https://github.com/arduino/reference-en/issues/362

It does work properly with Arduino.

For now use this sub instead:
B4X:
Sub MyAbs(d As Double) As Double
   If d < 0 Then Return -d Else Return d
End Sub
 
Upvote 0
Top