I want to convert a negative int/ double value into positive of the same, and use it for further calculations..i tried using %2 but the value turns out to be -0.0. It would be a great help if someone could help me out with this.
In Dart
you can do like this
value.abs()
In Kotlin
you can do like this
value.absoluteValue
In JavaScript
you can do like this
Math.abs(value)
If you only want to change negative numbers you could do:
if(num < 0)
num *= -1;
I'm just reiterating what diggersworld commented...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With