DigitMagazine

Basic Maths operations in Groovy

Jun 24th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. //Basic Maths operation
  2. println("5 + 6 => " + (5 + 6))
  3. println("5 - 6 => " + (5 - 6))
  4. println("5 * 6 => " + (5 * 6))
  5. println("5 / 6 => " + (5.intdiv(6))) //Look out for the method that is there in the number
  6. println("5 % 6 => " + (5 % 6))
  7.  
  8. //Floating Point operations
  9. println("5.1 + 6.1 => " + (5.1.plus(6.1))) //Methods can be replaced with operators also
  10. println("5.1 - 6.1 => " + (5.1.minus(6.1)))
  11. println("5.1 * 6.1 => " + (5.1.multiply(6.1)))
  12. println("5.1 / 6.1 => " + (5.1 / 6.1))
Add Comment
Please, Sign In to add comment