1 BC

Class Ax.math.bc


BCMath Arbitrary Precision Mathematics An extension to the basic calculator function for Arbitrary Precision Mathematics. WARNING: BC is STATIC! This class is injected as static (setStatic()) so it can be accessed using Ax.math.bc (without new) even it's methods are not declared static.

Method Summary

Modifier and Type
Method
Description
static Ax.java.math.BigDecimal 
abs(Number n1)
Returns the absolute value of the number.
static Ax.java.math.BigDecimal 
add(Number[] numbers)
Returns the sum of the parameters
static int 
compareTo(Number n1, Number n2)
Checks if n1 is bigger, equal or less than n2.
static Ax.java.math.BigDecimal 
div(Number n1,Number n2)
Returns the division of 2 numbers.
static Ax.java.math.BigDecimal 
div(Number n1, Number n2, int scale)
Returns the division of 2 numbers, with the specified scale (number of digits after the decimal point/comma).
static Ax.java.math.BigDecimal 
div(Number n1,Number n2,int scale,Ax.text.String roundingMode)
Returns the division of 2 numbers, with the specified scale (number of digits after the decimal point/comma) and rounding mode.
static boolean 
equals(Number n1, Number n2)
Checks if both numbers have the same value
static int 
getScale(Ax.java.math.BigDecimal n1)
Gets the scale of the number, that is, sets the number of digits after the decimal point/comma.
static boolean 
isZero(Number n1)
Checks if n1's value is 0.
static Ax.java.math.BigDecimal 
mul(Number[] numbers)
Returns the multiplication of all tne numbers
static Ax.java.math.BigDecimal 
of(Ax.text.String number)
Returns a BigDecimal from a String.
static Ax.java.math.BigDecimal 
of(Number number)
Returns a BigDecimal from a Number.
static Ax.java.math.BigDecimal 
pow(Number n1, int n2)
Returns n1 raised to the power of n2.
static Ax.java.math.BigDecimal 
round(Number n1,int precision)
Returns n1 rounded with the defined precision (number of digits).
static Ax.java.math.BigDecimal 
scale(Number n1, int scale)
Scales the number, that is, sets the number of digits after the decimal point/comma.
static Ax.java.math.BigDecimal 
scale(Number n1,int scale,RoundingMode mode)
Scales the number, that is, sets the number of digits after the decimal point/comma.
static Ax.java.math.BigDecimal 
sub(Number[] numbers)
Returns the subtraction of all the parameters from the first.
static Ax.math.BigInteger 
unscaledValue(Ax.java.math.BigDecimal n1)
Returns a number whose value is the unscaled value of n1.

Method Detail

Ax.math.bc.abs

static object Ax.math.bc.abs(
	object n1
)
Info:
Returns the absolute value of the number.
Parameters:
n1 - the number
Returns:
object

Ax.math.bc.add

static object Ax.math.bc.add(
	object numbers
)
Info:
Returns the sum of the parameters
Parameters:
numbers - the numbers to add
Returns:
object

Ax.math.bc.compareTo

static smallint Ax.math.bc.compareTo(
	object n1,
	object n2
)
Info:
Checks if n1 is bigger, equal or less than n2.
Parameters:
n1 - the first number to check
n2 - the second number to check
Returns:
smallint

Ax.math.bc.div

static object Ax.math.bc.div(
	object n1,
	object n2
)
Info:
Returns the division of 2 numbers.
Parameters:
n1 - the dividend
n2 - the divisor
Returns:
object

Ax.math.bc.div

static object Ax.math.bc.div(
	object n1,
	object n2,
	smallint scale
)
Info:
Returns the division of 2 numbers, with the specified scale (number of digits after the decimal point/comma).
Parameters:
n1 - the dividend
n2 - the divisor
scale - the scale of the quotient to be returned
Returns:
object

Ax.math.bc.div

static object Ax.math.bc.div(
	object n1,
	object n2,
	smallint scale,
	string roundingMode
)
Info:
Returns the division of 2 numbers, with the specified scale (number of digits after the decimal point/comma) and rounding mode.
Parameters:
n1 - the dividend
n2 - the divisor
scale - the scale of the quotient to be returned
roundingMode - the rounding mode: UP, DOWN, CEILING, FLOOR, HALF_UP, HALF_DOWN, HALF_EVEN, UNNECESSARY
Returns:
object

Ax.math.bc.equals

static boolean Ax.math.bc.equals(
	object n1,
	object n2
)
Info:
Checks if both numbers have the same value
Parameters:
n1 - the first number to check
n2 - the second number to check
Returns:
boolean

Ax.math.bc.getScale

static smallint Ax.math.bc.getScale(
	object n1
)
Info:
Gets the scale of the number, that is, sets the number of digits after the decimal point/comma.
Parameters:
n1 - the number
Returns:
smallint

Ax.math.bc.isZero

static boolean Ax.math.bc.isZero(
	object n1
)
Info:
Checks if n1's value is 0.
Parameters:
n1 - number to check
Returns:
boolean

Ax.math.bc.mul

static object Ax.math.bc.mul(
	object numbers
)
Info:
Returns the multiplication of all tne numbers
Parameters:
numbers - the numbers to multiply
Returns:
object

Ax.math.bc.of

static object Ax.math.bc.of(
	string number
)
Info:
Returns a BigDecimal from a String.
Parameters:
number - number in String format
Returns:
object

Ax.math.bc.of

static object Ax.math.bc.of(
	object number
)
Info:
Returns a BigDecimal from a Number.
Parameters:
number - number in Number format
Returns:
object

Ax.math.bc.pow

static object Ax.math.bc.pow(
	object n1,
	smallint n2
)
Info:
Returns n1 raised to the power of n2.
Parameters:
n1 - the base number
n2 - the exponent
Returns:
object

Ax.math.bc.round

static object Ax.math.bc.round(
	object n1,
	smallint precision
)
Info:
Returns n1 rounded with the defined precision (number of digits).
Parameters:
n1 - the number to round
precision - the precision to use
Returns:
object

Ax.math.bc.scale

static object Ax.math.bc.scale(
	object n1,
	smallint scale
)
Info:
Scales the number, that is, sets the number of digits after the decimal point/comma.
Parameters:
n1 - the number to scale
scale - the scale to use
Returns:
object

Ax.math.bc.scale

static object Ax.math.bc.scale(
	object n1,
	smallint scale,
	object mode
)
Info:
Scales the number, that is, sets the number of digits after the decimal point/comma.
Parameters:
n1 - the number to scale
scale - the scale to use
mode - the rounding mode: UP, DOWN, CEILING, FLOOR, HALF_UP, HALF_DOWN, HALF_EVEN, UNNECESSARY
Returns:
object

Ax.math.bc.sub

static object Ax.math.bc.sub(
	object numbers
)
Info:
Returns the subtraction of all the parameters from the first.
Parameters:
numbers - numbers to subtract, numbers[0] is the value the other numbers will subtract from
Returns:
object

Ax.math.bc.unscaledValue

static object Ax.math.bc.unscaledValue(
	object n1
)
Info:
Returns a number whose value is the unscaled value of n1.
Parameters:
n1 - the number to unscale
Returns:
object

2 Number

Class Ax.math.Number


Static class to convert Number objects to other numeric classes.

Constructor Summary

Method
Description

Method Summary

Modifier and Type
Method
Description
Ax.java.math.BigDecimal 
Returns the Number as an BigDecimal.
Ax.math.BigInteger 
Returns the Number as an BigInteger.
int 
Returns the Number as an integer.
long 
Returns the Number as a long.

Constructor Detail

Ax.math.Number.JSNumber

Ax.math.Number.JSNumber()

Method Detail

Ax.math.Number.toBigDecimal

object Ax.math.Number.toBigDecimal(
	object n
)
Info:
Returns the Number as an BigDecimal.
Parameters:
n - the number to convert
Returns:
object

Ax.math.Number.toBigInteger

object Ax.math.Number.toBigInteger(
	object n
)
Info:
Returns the Number as an BigInteger.
Parameters:
n - the number to convert
Returns:
object

Ax.math.Number.toInt

smallint Ax.math.Number.toInt(
	object n
)
Info:
Returns the Number as an integer.
Parameters:
n - the number to convert
Returns:
smallint

Ax.math.Number.toLong

long Ax.math.Number.toLong(
	object n
)
Info:
Returns the Number as a long.
Parameters:
n - the number to convert
Returns:
long

3 BigDecimal

Immutable, arbitrary-precision signed decimal numbers. A BigDecimal consists of an arbitrary precision integer unscaled value and a 32-bit integer scale.

BigDecimal documentation page.

4 BigInteger

Immutable arbitrary-precision integers. All operations behave as if BigIntegers were represented in two's-complement notation (like Java's primitive integer types).

BigInteger documentation page.