DigitMagazine

Math Functions in Groovy

Jun 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. //Math Functions
  2. def someNum = 2.5
  3. println("Math.abs(-2.45) = " + (Math.abs(-2.45)))
  4. println("Math.round(2.45) = " + (Math.round(2.45)))
  5. println("randNum.pow(3) = " + (someNum.pow(3)))
  6. println("3.0.equals(2.0) = " + (3.0.equals(2.0)))
  7. println("randNum.equals(Float.NaN) = " + (someNum.equals(Float.NaN)))
  8. println("Math.sqrt(9) = " + (Math.sqrt(9)))
  9. println("Math.cbrt(27) = " + (Math.cbrt(27)))
  10. println("Math.ceil(2.45) = " + (Math.ceil(2.45)))
  11. println("Math.floor(2.45) = " + (Math.floor(2.45)))
  12. println("Math.min(2,3) = " + (Math.min(2, 3)))
  13. println("Math.max(2,3) = " + (Math.max(2, 3)))
Add Comment
Please, Sign In to add comment