...
Integer division can be performed on the integral types by casting the result of the division. For example:
| Code Block |
|---|
assert (int)(3/2) == 1I;
|
Future versions of Groovy may support an integer division operator such as div and/or ÷.
...
| Code Block | ||
|---|---|---|
| ||
// y = 2 x^3 + 5 x^2 - 3 x + 2
def x = 5.0;
def y = 2.0 * Math.pow(x,3) + 5.0 * Math.pow(x,2) - 3.0*x + 2.0
|
...
| Code Block |
|---|
// y = 2 x^3 + 5 x^2 - 3 x + 2
def x = 5.0;
def y = 2.0*x**3 + 5.0*x**2 - 3.0*x + 2.0
|
...
| Code Block |
|---|
IntegerLiteral: Base10IntegerLiteral HexIntegerLiteral OctalIntegerLiteral Base10IntegerLiteral: Base10Numeral IntegerTypeSuffix (optional) HexIntegerLiteral: HexNumeral IntegerTypeSuffix (optional) OctalIntegerLiteral: OctalNumeral IntegerTypeSuffix (optional) IntegerTypeSuffix: one of i I l L g G Base10Numeral: 0 NonZeroDigit Digits (optional) Digits: Digit Digits Digit Digit: 0 NonZeroDigit NonZeroDigit: one of \1 2 3 4 5 6 7 8 9 HexNumeral: 0 x HexDigits 0 X HexDigits HexDigits: HexDigit HexDigit HexDigits HexDigit: one of 0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F OctalNumeral: 0 OctalDigits OctalDigits: OctalDigit OctalDigit OctalDigits OctalDigit: one of 0 1 2 3 4 5 6 7 DecimalPointLiteral: Digits . Digits ExponentPart (optional) DecimalTypeSuffix (optional) . Digits ExponentPart (optional) DecimalTypeSuffix (optional) Digits ExponentPart DecimalTypeSuffix (optional) Digits ExponentPart (optional) DecimalTypeSuffix (optional) ExponentPart: ExponentIndicator SignedInteger ExponentIndicator: one of e E SignedInteger: Signopt Digits Sign: one of + - DecimalTypeSuffix: one of f F d D g G |