Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
14
Task/Arithmetic-Integer/Groovy/arithmetic-integer-1.groovy
Normal file
14
Task/Arithmetic-Integer/Groovy/arithmetic-integer-1.groovy
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
def arithmetic = { a, b ->
|
||||
println """
|
||||
a + b = ${a} + ${b} = ${a + b}
|
||||
a - b = ${a} - ${b} = ${a - b}
|
||||
a * b = ${a} * ${b} = ${a * b}
|
||||
a / b = ${a} / ${b} = ${a / b} !!! Converts to floating point!
|
||||
(int)(a / b) = (int)(${a} / ${b}) = ${(int)(a / b)} !!! Truncates downward after the fact
|
||||
a.intdiv(b) = ${a}.intdiv(${b}) = ${a.intdiv(b)} !!! Behaves as if truncating downward, actual implementation varies
|
||||
a % b = ${a} % ${b} = ${a % b}
|
||||
|
||||
Exponentiation is also a base arithmetic operation in Groovy, so:
|
||||
a ** b = ${a} ** ${b} = ${a ** b}
|
||||
"""
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
arithmetic(5,3)
|
||||
Loading…
Add table
Add a link
Reference in a new issue