How to get the absolute value of a number in Groovy

1 Answer

0 votes
Integer n = -9
float f = -12356
double d = -3.14

println(Math.abs(n))
println(Math.abs(f))
println(Math.abs(d))




/*
run:

9
12356.0
3.14

*/

 



answered Oct 3, 2020 by avibootz
edited Oct 4, 2020 by avibootz

Related questions

1 answer 299 views
1 answer 241 views
1 answer 167 views
1 answer 298 views
2 answers 305 views
1 answer 260 views
2 answers 476 views
...