Class FloatingPointMath
Singleton instance providing NumberMath implementations for floating-point operations. Handles both Float and Double types using double-precision floating-point semantics. All results are returned as Double values to preserve precision.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final FloatingPointMathSingleton instance of FloatingPointMath. -
Method Summary
Modifier and TypeMethodDescriptionComputes the absolute value of a number.Adds two numbers.intcompareToImpl(Number left, Number right) Compares two numbers.divideImpl(Number left, Number right) Divides two numbers.Modulo of two numbers.multiplyImpl(Number left, Number right) Multiplies two numbers.remainderImpl(Number left, Number right) Remainder of two numbers.subtractImpl(Number left, Number right) Subtracts two numbers.unaryMinusImpl(Number left) Negates a number.unaryPlusImpl(Number left) Returns the number as-is (unary plus/identity).Methods inherited from class org.codehaus.groovy.runtime.typehandling.NumberMath
abs, add, and, andImpl, bitwiseNegate, bitwiseNegateImpl, compareTo, createUnsupportedException, divide, getMath, intdiv, intdivImpl, isBigDecimal, isBigInteger, isByte, isFloatingPoint, isInteger, isLong, isShort, leftShift, leftShiftImpl, mod, multiply, or, orImpl, remainder, rightShift, rightShiftImpl, rightShiftUnsigned, rightShiftUnsignedImpl, subtract, toBigDecimal, toBigInteger, unaryMinus, unaryPlus, xor, xorImpl
-
Field Details
-
INSTANCE
Singleton instance of FloatingPointMath.
-
-
Method Details
-
absImpl
Description copied from class:NumberMathComputes the absolute value of a number.Subclasses must implement this method according to type promotion hierarchy rules.
- Specified by:
absImplin classNumberMath- Parameters:
number- the operand- Returns:
- the absolute value
-
addImpl
Description copied from class:NumberMathAdds two numbers.Subclasses must implement this method according to type promotion hierarchy rules.
- Specified by:
addImplin classNumberMath- Parameters:
left- the left operandright- the right operand- Returns:
- the sum
-
subtractImpl
Description copied from class:NumberMathSubtracts two numbers.Subclasses must implement this method according to type promotion hierarchy rules.
- Specified by:
subtractImplin classNumberMath- Parameters:
left- the minuendright- the subtrahend- Returns:
- the difference
-
multiplyImpl
Description copied from class:NumberMathMultiplies two numbers.Subclasses must implement this method according to type promotion hierarchy rules.
- Specified by:
multiplyImplin classNumberMath- Parameters:
left- the first multiplicandright- the second multiplicand- Returns:
- the product
-
divideImpl
Description copied from class:NumberMathDivides two numbers.Subclasses must implement this method according to type promotion hierarchy rules.
- Specified by:
divideImplin classNumberMath- Parameters:
left- the dividendright- the divisor- Returns:
- the quotient
-
compareToImpl
Description copied from class:NumberMathCompares two numbers.Subclasses must implement this method according to type promotion hierarchy rules.
- Specified by:
compareToImplin classNumberMath- Parameters:
left- the first numberright- the second number- Returns:
- negative, zero, or positive as left is less than, equal to, or greater than right
-
remainderImpl
Description copied from class:NumberMathRemainder of two numbers.Default implementation throws UnsupportedOperationException. Subclasses supporting remainder must override.
- Overrides:
remainderImplin classNumberMath- Parameters:
left- the dividendright- the divisor- Returns:
- the remainder
-
modImpl
Description copied from class:NumberMathModulo of two numbers.Default implementation throws UnsupportedOperationException. Subclasses supporting modulo must override.
- Overrides:
modImplin classNumberMath- Parameters:
left- the dividendright- the divisor- Returns:
- the modulo result
-
unaryMinusImpl
Description copied from class:NumberMathNegates a number.Subclasses must implement this method according to type promotion hierarchy rules.
- Specified by:
unaryMinusImplin classNumberMath- Parameters:
left- the operand- Returns:
- the negation
-
unaryPlusImpl
Description copied from class:NumberMathReturns the number as-is (unary plus/identity).Subclasses must implement this method according to type promotion hierarchy rules.
- Specified by:
unaryPlusImplin classNumberMath- Parameters:
left- the operand- Returns:
- the same value
-