Is there a reason why ```public actual fun abs(n: ...
# javascript
e
Is there a reason why
Copy code
public actual fun abs(n: Int): Int = if (n < 0) (-n or 0) else n
is not using
nativeMath.abs(n)
like its double or float counterparts?
e
that wouldn't have the same result on
abs(Int.MIN_VALUE)
gratitude thank you 1
e
So it's done to align its behavior to the JVM platform pretty much
e
ending up with a
Int.MAX_VALUE + 1
value in an
Int
type would be pretty broken, so…
e
Yeah definitely ahaha, thanks for spotting that comment, should have read more carefully.