java.math
4 classes of the module java.base.
Load them with:
using {
"java.math"
}
BigDecimal#
class · extends Number · java.math.BigDecimal
Implements: Comparable
Constructors
new BigDecimal(BigInteger val) |
new BigDecimal(long val) |
new BigDecimal(int val) |
new BigDecimal(char[] in) |
new BigDecimal(double val) |
new BigDecimal(String val) |
new BigDecimal(BigInteger unscaledVal, int scale) |
new BigDecimal(BigInteger val, MathContext mc) |
new BigDecimal(long val, MathContext mc) |
new BigDecimal(double val, MathContext mc) |
new BigDecimal(int val, MathContext mc) |
new BigDecimal(String val, MathContext mc) |
new BigDecimal(char[] in, MathContext mc) |
new BigDecimal(BigInteger unscaledVal, int scale, MathContext mc) |
new BigDecimal(char[] in, int offset, int len) |
new BigDecimal(char[] in, int offset, int len, MathContext mc) |
Ring: new BigDecimal(args) uses the constructor with the fewest parameters (at least one); new BigDecimal makes the object with the constructor without parameters; the others: (new BigDecimal).@New([ :param = value ]) or .@New([v1,v2]).
Fields
| Name | Type | Access | In Ring |
|---|---|---|---|
ZERO | BigDecimal | constant · static | o.ZERO |
ONE | BigDecimal | constant · static | o.ONE |
TWO | BigDecimal | constant · static | o.TWO |
TEN | BigDecimal | constant · static | o.TEN |
ROUND_UP | int | constant · static | o.ROUND_UP |
ROUND_DOWN | int | constant · static | o.ROUND_DOWN |
ROUND_CEILING | int | constant · static | o.ROUND_CEILING |
ROUND_FLOOR | int | constant · static | o.ROUND_FLOOR |
ROUND_HALF_UP | int | constant · static | o.ROUND_HALF_UP |
ROUND_HALF_DOWN | int | constant · static | o.ROUND_HALF_DOWN |
ROUND_HALF_EVEN | int | constant · static | o.ROUND_HALF_EVEN |
ROUND_UNNECESSARY | int | constant · static | o.ROUND_UNNECESSARY |
Methods
| Method | Ring call | Java overloads |
|---|---|---|
@abs | @abs(mc) | BigDecimal abs(MathContext mc) |
@negate | @negate(mc) | BigDecimal negate(MathContext mc) |
@plus | @plus(mc) | BigDecimal plus(MathContext mc) |
abs | abs() | BigDecimal abs() |
add | add(augend)add([augend,mc])add([ :augend = v, :mc = v ]) | BigDecimal add(BigDecimal augend)BigDecimal add(BigDecimal augend, MathContext mc) |
byteValueExact | byteValueExact() | byte byteValueExact() |
compareTo | compareTo(val) | int compareTo(BigDecimal val) |
divide | divide(divisor)divide([divisor,roundingMode])divide([ :divisor = v, :roundingMode = v ])divide([divisor,scale,roundingMode])divide([ :divisor = v, :scale = v, :roundingMode = v ]) | BigDecimal divide(BigDecimal divisor)BigDecimal divide(BigDecimal divisor, RoundingMode roundingMode)BigDecimal divide(BigDecimal divisor, int roundingMode)BigDecimal divide(BigDecimal divisor, MathContext mc)BigDecimal divide(BigDecimal divisor, int scale, RoundingMode roundingMode)BigDecimal divide(BigDecimal divisor, int scale, int roundingMode) |
divideAndRemainder | divideAndRemainder(divisor)divideAndRemainder([divisor,mc])divideAndRemainder([ :divisor = v, :mc = v ]) | BigDecimal[] divideAndRemainder(BigDecimal divisor)BigDecimal[] divideAndRemainder(BigDecimal divisor, MathContext mc) |
divideToIntegralValue | divideToIntegralValue(divisor)divideToIntegralValue([divisor,mc])divideToIntegralValue([ :divisor = v, :mc = v ]) | BigDecimal divideToIntegralValue(BigDecimal divisor)BigDecimal divideToIntegralValue(BigDecimal divisor, MathContext mc) |
intValueExact | intValueExact() | int intValueExact() |
longValueExact | longValueExact() | long longValueExact() |
max | max(val) | BigDecimal max(BigDecimal val) |
min | min(val) | BigDecimal min(BigDecimal val) |
movePointLeft | movePointLeft(n) | BigDecimal movePointLeft(int n) |
movePointRight | movePointRight(n) | BigDecimal movePointRight(int n) |
multiply | multiply(multiplicand)multiply([multiplicand,mc])multiply([ :multiplicand = v, :mc = v ]) | BigDecimal multiply(BigDecimal multiplicand)BigDecimal multiply(BigDecimal multiplicand, MathContext mc) |
negate | negate() | BigDecimal negate() |
plus | plus() | BigDecimal plus() |
pow | pow(n)pow([n,mc])pow([ :n = v, :mc = v ]) | BigDecimal pow(int n)BigDecimal pow(int n, MathContext mc) |
precision | precision() | int precision() |
remainder | remainder(divisor)remainder([divisor,mc])remainder([ :divisor = v, :mc = v ]) | BigDecimal remainder(BigDecimal divisor)BigDecimal remainder(BigDecimal divisor, MathContext mc) |
round | round(mc) | BigDecimal round(MathContext mc) |
scale | scale() | int scale() |
scaleByPowerOfTen | scaleByPowerOfTen(n) | BigDecimal scaleByPowerOfTen(int n) |
setScale | setScale(newScale)setScale([newScale,roundingMode])setScale([ :newScale = v, :roundingMode = v ]) | BigDecimal setScale(int newScale)BigDecimal setScale(int newScale, RoundingMode roundingMode)BigDecimal setScale(int newScale, int roundingMode) |
shortValueExact | shortValueExact() | short shortValueExact() |
signum | signum() | int signum() |
sqrt | sqrt(mc) | BigDecimal sqrt(MathContext mc) |
stripTrailingZeros | stripTrailingZeros() | BigDecimal stripTrailingZeros() |
subtract | subtract(subtrahend)subtract([subtrahend,mc])subtract([ :subtrahend = v, :mc = v ]) | BigDecimal subtract(BigDecimal subtrahend)BigDecimal subtract(BigDecimal subtrahend, MathContext mc) |
toBigInteger | toBigInteger() | BigInteger toBigInteger() |
toBigIntegerExact | toBigIntegerExact() | BigInteger toBigIntegerExact() |
toEngineeringString | toEngineeringString() | String toEngineeringString() |
toPlainString | toPlainString() | String toPlainString() |
ulp | ulp() | BigDecimal ulp() |
unscaledValue | unscaledValue() | BigInteger unscaledValue() |
valueOf | valueOf(val)valueOf([unscaledVal,scale])valueOf([ :unscaledVal = v, :scale = v ]) | static BigDecimal valueOf(long val)static BigDecimal valueOf(double val)static BigDecimal valueOf(long unscaledVal, int scale) |
The methods and fields of Number are inherited.
BigInteger#
class · extends Number · java.math.BigInteger
Implements: Comparable
Constructors
new BigInteger(String val) |
new BigInteger(byte[] val) |
new BigInteger(int numBits, Random rnd) |
new BigInteger(String val, int radix) |
new BigInteger(int signum, byte[] magnitude) |
new BigInteger(int bitLength, int certainty, Random rnd) |
new BigInteger(byte[] val, int off, int len) |
new BigInteger(int signum, byte[] magnitude, int off, int len) |
Ring: new BigInteger(args) uses the constructor with the fewest parameters (at least one); new BigInteger makes the object with the constructor without parameters; the others: (new BigInteger).@New([ :param = value ]) or .@New([v1,v2]).
Fields
| Name | Type | Access | In Ring |
|---|---|---|---|
ZERO | BigInteger | constant · static | o.ZERO |
ONE | BigInteger | constant · static | o.ONE |
TWO | BigInteger | constant · static | o.TWO |
TEN | BigInteger | constant · static | o.TEN |
Methods
| Method | Ring call | Java overloads |
|---|---|---|
@and | @and(val) | BigInteger and(BigInteger val) |
@not | @not() | BigInteger not() |
@or | @or(val) | BigInteger or(BigInteger val) |
@toString | @toString(radix) | String toString(int radix) |
abs | abs() | BigInteger abs() |
add | add(val) | BigInteger add(BigInteger val) |
andNot | andNot(val) | BigInteger andNot(BigInteger val) |
bitCount | bitCount() | int bitCount() |
bitLength | bitLength() | int bitLength() |
byteValueExact | byteValueExact() | byte byteValueExact() |
clearBit | clearBit(n) | BigInteger clearBit(int n) |
compareTo | compareTo(val) | int compareTo(BigInteger val) |
divide | divide(val) | BigInteger divide(BigInteger val) |
divideAndRemainder | divideAndRemainder(val) | BigInteger[] divideAndRemainder(BigInteger val) |
flipBit | flipBit(n) | BigInteger flipBit(int n) |
gcd | gcd(val) | BigInteger gcd(BigInteger val) |
getLowestSetBit | getLowestSetBit() | int getLowestSetBit() |
intValueExact | intValueExact() | int intValueExact() |
isProbablePrime | isProbablePrime(certainty) | boolean isProbablePrime(int certainty) |
longValueExact | longValueExact() | long longValueExact() |
max | max(val) | BigInteger max(BigInteger val) |
min | min(val) | BigInteger min(BigInteger val) |
mod | mod(m) | BigInteger mod(BigInteger m) |
modInverse | modInverse(m) | BigInteger modInverse(BigInteger m) |
modPow | modPow(exponent,m) | BigInteger modPow(BigInteger exponent, BigInteger m) |
multiply | multiply(val) | BigInteger multiply(BigInteger val) |
negate | negate() | BigInteger negate() |
nextProbablePrime | nextProbablePrime() | BigInteger nextProbablePrime() |
parallelMultiply | parallelMultiply(val) | BigInteger parallelMultiply(BigInteger val) |
pow | pow(exponent) | BigInteger pow(int exponent) |
probablePrime | probablePrime(bitLength,rnd) | static BigInteger probablePrime(int bitLength, Random rnd) |
remainder | remainder(val) | BigInteger remainder(BigInteger val) |
setBit | setBit(n) | BigInteger setBit(int n) |
shiftLeft | shiftLeft(n) | BigInteger shiftLeft(int n) |
shiftRight | shiftRight(n) | BigInteger shiftRight(int n) |
shortValueExact | shortValueExact() | short shortValueExact() |
signum | signum() | int signum() |
sqrt | sqrt() | BigInteger sqrt() |
sqrtAndRemainder | sqrtAndRemainder() | BigInteger[] sqrtAndRemainder() |
subtract | subtract(val) | BigInteger subtract(BigInteger val) |
testBit | testBit(n) | boolean testBit(int n) |
toByteArray | toByteArray() | byte[] toByteArray() |
valueOf | valueOf(val) | static BigInteger valueOf(long val) |
xor | xor(val) | BigInteger xor(BigInteger val) |
The methods and fields of Number are inherited.
MathContext#
class final · extends Object · java.math.MathContext
Implements: Serializable
Constructors
new MathContext(String val) |
new MathContext(int setPrecision) |
new MathContext(int setPrecision, RoundingMode setRoundingMode) |
Ring: new MathContext(args) uses the constructor with the fewest parameters (at least one); new MathContext makes the object with the constructor without parameters; the others: (new MathContext).@New([ :param = value ]) or .@New([v1,v2]).
Fields
| Name | Type | Access | In Ring |
|---|---|---|---|
UNLIMITED | MathContext | constant · static | o.UNLIMITED |
DECIMAL32 | MathContext | constant · static | o.DECIMAL32 |
DECIMAL64 | MathContext | constant · static | o.DECIMAL64 |
DECIMAL128 | MathContext | constant · static | o.DECIMAL128 |
Methods
| Method | Ring call | Java overloads |
|---|---|---|
getPrecision | getPrecision() | int getPrecision() |
getRoundingMode | getRoundingMode() | RoundingMode getRoundingMode() |
The methods and fields of Object are inherited.
RoundingMode#
enum · extends Enum · java.math.RoundingMode
Fields
| Name | Type | Access | In Ring |
|---|---|---|---|
UP | RoundingMode | constant · static | o.UP |
DOWN | RoundingMode | constant · static | o.DOWN |
CEILING | RoundingMode | constant · static | o.CEILING |
FLOOR | RoundingMode | constant · static | o.FLOOR |
HALF_UP | RoundingMode | constant · static | o.HALF_UP |
HALF_DOWN | RoundingMode | constant · static | o.HALF_DOWN |
HALF_EVEN | RoundingMode | constant · static | o.HALF_EVEN |
UNNECESSARY | RoundingMode | constant · static | o.UNNECESSARY |
Methods
| Method | Ring call | Java overloads |
|---|---|---|
valueOf | valueOf(rm)valueOf([enumClass,name])valueOf([ :enumClass = v, :name = v ]) | static RoundingMode valueOf(String rm)static RoundingMode valueOf(int rm)static Enum valueOf(Class enumClass, String name) |
values | values() | static RoundingMode[] values() |
The methods and fields of Enum are inherited.