/ Published in: Groovy
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//the two most common number classes //you can explicitly create Long, Float and Double with L / F / D def longObj = 20L def floatObj = 40.45F def doubleObj = 34.45D //if G is used, it checks if the number has a decimal point, then creates a BigInteger or BigDecimal def bigIntegerObj = 50G //some coercion stuff //multiplication, addition and substraction between two floats results in a double //multiplication, addition and substraction with BigInteger or BigDecimal results in BigInteger or BigDecimal //multiplication of two integers //multiplication with Long //dividing some numbers //if you want an integer, use the intdiv() method //some GDK methods for numbers //think about a java for loop... you don't need it! 11.downto(10) { numbers << it} numbers = [] numbers = []