Groovy 6 – Math Operators November 1, 2020November 16, 2023rvtechblog Normal Arithmetic Operators Operator Purpose+addition–subtraction*multiplication/division%remainder or modulus**power EXAMPLESAddition6 + 1 = 7Subtractions3 -2 = 1Multiplication2 * 2 = 4Division6 / 2 = 6Remainder or Modulus10 % 3 = 1Power3 ** 2 = 9 Assignment arithmetic operatorsOperator Purpose+=Addition Assignment -=Substation Assignment *=Multiplication Assignment /=Division Assignment %=Modulus Assignment EXAMPLES Addition Assignment a+=4 can be also be written as a = a + 4 def a = 3a+=5 (a = 3 + 5) will result in a = 8 Substation Assignment a-=2 can be also be written as a = a – 2 def a = 5a-=2 (a = 5 – 2) will result in a = 3 Multiplication Assignmenta*=2 can be also be written as a = a * 4 def a = 2a*=3(a = 2 * 3) will result in a = 6 Division Assignment a/=2 can be also be written as a = a / 2 def a = 10a/=2 (a = 10 / 2) will result in a =5 Modulus Assignmenta%=3 can be also be written as a = a % 3 def a = 10a%=3 (a = 10% 3) will result in a =1Increment/Decrement operatorsOperator Purpose++Increment—DecrementEXAMPLES Incrementa++ can be also be written as a = a + 1 def a = 10a++ will result in 11 Decrementa– can be also be written as a = a – 1 def a = 10a– will result in 9