Package net.sourceforge.uiq3.math
Interface Number
-
- All Superinterfaces:
Cloneable
,Comparable<Number>
- All Known Implementing Classes:
BCDFloat
,BCDFraction
,BCDInteger
public interface Number extends Cloneable, Comparable<Number>
An arithmetic number.
-
-
Field Summary
Fields Modifier and Type Field Description static int
Compare_Equal
Compare result.static int
Compare_Greater
Compare result.static int
Compare_Less
Compare result.static int
Effective_Precision
Effectivly needed precision.static int
Max_Precision
Max supported precision.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description @NotNull Number
$div(@NotNull Number y)
x ÷ y@NotNull Number
$minus(@NotNull Number y)
x - y@NotNull Number
$plus(@NotNull Number y)
x + y@NotNull Number
$times(@NotNull Number y)
x × y@NotNull Number
$times$times(@NotNull Number y)
xy@NotNull Number
abs()
|x|@NotNull Number
and(@NotNull Number y)
Logical and@NotNull Number
arc_cos()
arc cosine@NotNull Number
arc_cos(@NotNull Number Half_Circle)
arc cosine@NotNull Number
arc_cos_hyp()
area hyperbolic cosine: loge (x + √(x-1) × √(x+1))@NotNull Number
arc_sin()
arc sine@NotNull Number
arc_sin(@NotNull Number Half_Circle)
arc sine@NotNull Number
arc_sin_hyp()
area hyperbolic sine: loge (x + √(x² + 1))@NotNull Number
arc_tan()
arc tangent@NotNull Number
arc_tan(@NotNull Number Half_Circle)
arc tangent@NotNull Number
arc_tan_hyp()
area hyperbolic tangent: loge ((1 + x) ÷ (1 - x)) / 2@NotNull BCDFloat
As_BCDFloat()
Either convert to a BCDFloat or return this.@NotNull BCDFraction
As_BCDFraction()
Either convert to a or return this.@NotNull BCDInteger
As_BCDInteger()
Either convert to a BCDInteger or return this.@NotNull Number
Clone()
clone the float - but it might be easier to use the provided copy Constructor instead.long
Coefficient_As_Long()
coefficient - while a 18 digits number can also be represented as an long an 18digits multiplication need a 36digits temporary and that is more then a long can do.int
Compare(@NotNull Number Value)
Compare valuesint
compareTo(@NotNull Number rightValue)
@NotNull Number
cos()
cos (x)@NotNull Number
cos(@NotNull Number Half_Circle)
cosine@NotNull Number
cos_hyp()
Hyperbolic cosine: (Exponent^x + Exponent^-x)/2byte[]
Digits()
number: sum(i = 0 ...default @NotNull Number
div(@NotNull Number y)
x ÷ yboolean
equals(@NotNull Object rightValue)
@NotNull Number
exp_10()
10x@NotNull Number
exp_e()
exint
Exponent()
current exponent - note that the exponent is based on the internal representation where the radix point is right most.@NotNull Number
Fix(int Decimal, int Exponent)
Round to a given Precision after the decimal point.@NotNull Number
Frac()
Recompose a frac double from the given data.int
Indirect_Value(int Digit_Count)
Get valuef or indirect addressing.@NotNull Number
Integer()
integer part of the BCDFloatboolean
Is_Finite()
current value is a normal numberboolean
Is_Infinite()
current value is Infinity (but not N/A).boolean
Is_Integer()
Current value is integer value.boolean
Is_NaN()
current value is not a numberboolean
Is_Negative()
Current value us negativeboolean
Is_Zero()
value is 0@NotNull Number
log_10()
log10 (x)@NotNull Number
log_e()
loge (x)default @NotNull Number
minus(@NotNull Number y)
x - y@NotNull Number
neg()
void
Normalize()
normalize the value@NotNull Number
not()
Logical notint
Num_Digits()
the current number of digits - not that when the number is not normalised there might be more 0's in the number then strictly needed.@NotNull Number
or(@NotNull Number y)
Logical or@NotNull Number
P_To_X(@NotNull Number θ)
Convert Polar to Rectangle Coordinates@NotNull Number
P_To_X(@NotNull Number θ, @NotNull Number Half_Circle)
Convert Polar to Rectangle Coordinates@NotNull Number
P_To_Y(@NotNull Number θ)
Convert Polar to Rectangle Coordinates@NotNull Number
P_To_Y(@NotNull Number θ, @NotNull Number Half_Circle)
Convert Polar to Rectangle Coordinatesdefault @NotNull Number
plus(@NotNull Number y)
x + ydefault @NotNull Number
pow(@NotNull Number y)
xy@NotNull Number
R_To_R(@NotNull Number y)
Convert Rectangle to Polar Coordinates@NotNull Number
R_To_θ(@NotNull Number y)
Convert Rectangle to Polar Coordinates@NotNull Number
R_To_θ(@NotNull Number y, @NotNull Number Half_Circle)
Convert Rectangle to Polar Coordinates@NotNull Number
root(@NotNull Number r)
r√x@NotNull Number
Round()
Round to effective Precision and Exponent.@NotNull Number
Round(int Precision, int Exponent)
Round to a given Precision and Exponent.@NotNull Number
sin()
sine@NotNull Number
sin(@NotNull Number Half_Circle)
sine@NotNull Number
sin_hyp()
hyperbolic sine: (ex - e-x) ÷ 2@NotNull Number
square()
x2@NotNull Number
square_root()
2√x@NotNull Number
tan()
tan x@NotNull Number
tan(@NotNull Number Half_Circle)
tangent@NotNull Number
tan_hyp()
Hyperbolic tangent: (e2x - 1) ÷ (e2x + 1)default @NotNull Number
times(@NotNull Number y)
x × y@NotNull String
To_Debug_String()
convert to native/debug string representationint
To_Integer()
Convert to integerlong
To_Long()
Convert to long integer@NotNull String
toString()
display as human readable string.@NotNull Number
xor(@NotNull Number y)
Logical xor
-
-
-
Field Detail
-
Compare_Equal
static final int Compare_Equal
Compare result.- Compare_Equal
- Values are the same
- Compare_Less
- Left value less the right value
- Compare_Greater
- Left value greater the right value
- See Also:
- Constant Field Values
-
Compare_Greater
static final int Compare_Greater
Compare result.- Compare_Equal
- Values are the same
- Compare_Less
- Left value less the right value
- Compare_Greater
- Left value greater the right value
- See Also:
- Constant Field Values
-
Compare_Less
static final int Compare_Less
Compare result.- Compare_Equal
- Values are the same
- Compare_Less
- Left value less the right value
- Compare_Greater
- Left value greater the right value
- See Also:
- Constant Field Values
-
Effective_Precision
static final int Effective_Precision
Effectivly needed precision. Both calculators only need 12 digits.- See Also:
- Constant Field Values
-
Max_Precision
static final int Max_Precision
Max supported precision. Fixed at 18 digits because:- 18 digits is more the enough for simulated calculators - most of which have only 12 digits precision
- 18 digits mantissa can also be represented as a long.
- See Also:
- Constant Field Values
-
-
Method Detail
-
$div
@NotNull @Contract(pure=true) @NotNull Number $div(@NotNull @NotNull Number y)
x ÷ y- Parameters:
y
- divisor- Returns:
- x ÷ y
-
div
@NotNull @Contract(pure=true) default @NotNull Number div(@NotNull @NotNull Number y)
x ÷ y- Parameters:
y
- divisor- Returns:
- x ÷ y
-
$minus
@NotNull @Contract(pure=true) @NotNull Number $minus(@NotNull @NotNull Number y)
x - y- Parameters:
y
- value to subtract- Returns:
- x - y
-
minus
@NotNull @Contract(pure=true) default @NotNull Number minus(@NotNull @NotNull Number y)
x - y- Parameters:
y
- value to subtract- Returns:
- x - y
-
$plus
@NotNull @Contract(pure=true) @NotNull Number $plus(@NotNull @NotNull Number y)
x + y- Parameters:
y
- value to add- Returns:
- x + y
-
plus
@NotNull @Contract(pure=true) default @NotNull Number plus(@NotNull @NotNull Number y)
x + y- Parameters:
y
- value to add- Returns:
- x + y
-
$times
@NotNull @Contract(pure=true) @NotNull Number $times(@NotNull @NotNull Number y)
x × y- Parameters:
y
- Multiplier- Returns:
- x × y
-
times
@NotNull @Contract(pure=true) default @NotNull Number times(@NotNull @NotNull Number y)
x × y- Parameters:
y
- Multiplier- Returns:
- x × y
-
$times$times
@NotNull @Contract(pure=true) @NotNull Number $times$times(@NotNull @NotNull Number y) throws BCDError
xy- Parameters:
y
- power- Returns:
- xy
- Throws:
BCDError
- calculation error
-
pow
@NotNull @Contract(pure=true) default @NotNull Number pow(@NotNull @NotNull Number y) throws BCDError
xy- Parameters:
y
- power- Returns:
- xy
- Throws:
BCDError
- calculation error
-
abs
@NotNull @Contract(pure=true) @NotNull Number abs()
|x|- Returns:
- abs value
-
and
@NotNull @Contract(pure=true) @NotNull Number and(@NotNull @NotNull Number y)
Logical and- Returns:
- x ∧ y
-
arc_cos
@NotNull @Contract(pure=true) @NotNull Number arc_cos()
arc cosine- Returns:
- arc cosine
-
arc_cos
@NotNull @Contract(pure=true) @NotNull Number arc_cos(@NotNull @NotNull Number Half_Circle)
arc cosine- Parameters:
Half_Circle
- value for a half circle- Returns:
- arccos (x) ÷ π × Half_Circle
-
arc_cos_hyp
@NotNull @Contract(pure=true) @NotNull Number arc_cos_hyp()
area hyperbolic cosine: loge (x + √(x-1) × √(x+1))- Returns:
- Hyperbolic sine.
-
arc_sin
@NotNull @Contract(pure=true) @NotNull Number arc_sin()
arc sine- Returns:
- arc sine
-
arc_sin
@NotNull @Contract(pure=true) @NotNull Number arc_sin(@NotNull @NotNull Number Half_Circle)
arc sine- Parameters:
Half_Circle
- value for a half circle- Returns:
- arcsin (x) ÷ π × Half_Circle
-
arc_sin_hyp
@NotNull @Contract(pure=true) @NotNull Number arc_sin_hyp()
area hyperbolic sine: loge (x + √(x² + 1))- Returns:
- Hyperbolic sine.
-
arc_tan
@NotNull @Contract(pure=true) @NotNull Number arc_tan()
arc tangent- Returns:
- arc tangent
-
arc_tan
@NotNull @Contract(pure=true) @NotNull Number arc_tan(@NotNull @NotNull Number Half_Circle)
arc tangent- Parameters:
Half_Circle
- value for a half circle- Returns:
- arctan (x) ÷ π × Half_Circle
-
arc_tan_hyp
@NotNull @Contract(pure=true) @NotNull Number arc_tan_hyp()
area hyperbolic tangent: loge ((1 + x) ÷ (1 - x)) / 2- Returns:
- Hyperbolic sine.
-
As_BCDFloat
@NotNull @NotNull BCDFloat As_BCDFloat()
Either convert to a BCDFloat or return this.- Returns:
- value as java int
-
As_BCDFraction
@NotNull @NotNull BCDFraction As_BCDFraction()
Either convert to a or return this.- Returns:
- value as java int
-
As_BCDInteger
@NotNull @NotNull BCDInteger As_BCDInteger()
Either convert to a BCDInteger or return this.- Returns:
- value as java int
-
Clone
@NotNull @NotNull Number Clone()
clone the float - but it might be easier to use the provided copy Constructor instead.- Returns:
- a new BCDFloat from an existing one.
- See Also:
Object.clone()
-
Coefficient_As_Long
long Coefficient_As_Long() throws BCDError
coefficient - while a 18 digits number can also be represented as an long an 18digits multiplication need a 36digits temporary and that is more then a long can do.- Returns:
- Coefficient
- Throws:
BCDError
- when it's not a normal number
-
Compare
int Compare(@NotNull @NotNull Number Value) throws BCDError
Compare values- Parameters:
Value
- Value to compare with- Returns:
- Compare_Equal
- Values are the same
- Compare_Less
- Left value less the right value
- Compare_Greater
- Left value greater the right value
- Throws:
BCDError
- numbers can not be compared.
-
compareTo
int compareTo(@NotNull @NotNull Number rightValue)
- Specified by:
compareTo
in interfaceComparable<Number>
- Parameters:
rightValue
- value to compare with- Returns:
- Compare_Equal
- Values are the same
- Compare_Less
- Left value less the right value
- Compare_Greater
- Left value greater the right value
- See Also:
Comparable.compareTo(Object)
-
cos
@NotNull @Contract(pure=true) @NotNull Number cos()
cos (x)- Returns:
- cos (x)
-
cos
@NotNull @Contract(pure=true) @NotNull Number cos(@NotNull @NotNull Number Half_Circle)
cosine- Parameters:
Half_Circle
- value for a half circle- Returns:
- sin (x × π ÷ Half_Circle)
-
cos_hyp
@NotNull @Contract(pure=true) @NotNull Number cos_hyp()
Hyperbolic cosine: (Exponent^x + Exponent^-x)/2- Returns:
- Hyperbolic cosine.
-
Digits
byte[] Digits()
number: sum(i = 0 ... Num_Digits-1; Digits[i]*10^i)
-
equals
boolean equals(@NotNull @NotNull Object rightValue)
-
exp_10
@NotNull @Contract(pure=true) @NotNull Number exp_10() throws BCDError
10x- Returns:
- 10x
- Throws:
BCDError
- calculation error
-
exp_e
@NotNull @Contract(pure=true) @NotNull Number exp_e()
ex- Returns:
- ex
-
Exponent
int Exponent() throws BCDError
current exponent - note that the exponent is based on the internal representation where the radix point is right most. For example π is 314159265358979324×10-17.- Returns:
- Current exponent.
- Throws:
BCDError
- when the value is not finite
-
Fix
@NotNull @NotNull Number Fix(int Decimal, int Exponent)
Round to a given Precision after the decimal point.- Parameters:
Decimal
- decimal digits to keepExponent
- max exponent- Returns:
- rounded value
-
Frac
@NotNull @NotNull Number Frac()
Recompose a frac double from the given data.- Returns:
- a double
-
Indirect_Value
int Indirect_Value(int Digit_Count)
Get valuef or indirect addressing.- Parameters:
Digit_Count
- Should be 1 … 2 depending if value is used to access memory or perform a goto.- Returns:
- int value for indirect addressing.
-
Integer
@NotNull @NotNull Number Integer()
integer part of the BCDFloatDo not mix up with To_Integer - This version returns another BCDFloat!
- Returns:
- integer part of this
-
Is_Finite
boolean Is_Finite()
current value is a normal number- Returns:
- true when it is a normal number
-
Is_Infinite
boolean Is_Infinite()
current value is Infinity (but not N/A).- Returns:
- true when x is infinite
-
Is_Integer
boolean Is_Integer()
Current value is integer value.- Returns:
- true when x is an integer number
-
Is_NaN
boolean Is_NaN()
current value is not a number- Returns:
- when is not a number
-
Is_Negative
boolean Is_Negative()
Current value us negative- Returns:
- true when x <= -0
-
Is_Zero
boolean Is_Zero()
value is 0- Returns:
- true when x is 0
-
log_10
@NotNull @Contract(pure=true) @NotNull Number log_10()
log10 (x)- Returns:
- log10 (x)
-
log_e
@NotNull @Contract(pure=true) @NotNull Number log_e()
loge (x)- Returns:
- loge (x)
-
neg
@NotNull @Contract(pure=true) @NotNull Number neg()
- Returns:
- negative value
-
Normalize
void Normalize()
normalize the valuedepending on type: remove leading zeros and / or trailing zeros
-
not
@NotNull @Contract(pure=true) @NotNull Number not()
Logical not- Returns:
- ¬ x
-
Num_Digits
int Num_Digits() throws BCDError
the current number of digits - not that when the number is not normalised there might be more 0's in the number then strictly needed.- Returns:
- number of digits
- Throws:
BCDError
- not a finite number
-
or
@NotNull @Contract(pure=true) @NotNull Number or(@NotNull @NotNull Number y)
Logical or- Parameters:
y
- right value- Returns:
- x ∨ y
-
P_To_X
@NotNull @Contract(pure=true) @NotNull Number P_To_X(@NotNull @NotNull Number θ)
Convert Polar to Rectangle Coordinates- Parameters:
\u03b8
- angle- Returns:
- x = cos (θ) × r
-
P_To_X
@NotNull @Contract(pure=true) @NotNull Number P_To_X(@NotNull @NotNull Number θ, @NotNull @NotNull Number Half_Circle)
Convert Polar to Rectangle Coordinates- Parameters:
\u03b8
- angleHalf_Circle
- 180 for deg, 200 for gra, pi for rad- Returns:
- x = cos (θ) × r
-
P_To_Y
@NotNull @Contract(pure=true) @NotNull Number P_To_Y(@NotNull @NotNull Number θ)
Convert Polar to Rectangle Coordinates- Parameters:
\u03b8
- angle- Returns:
- y = sin (θ) × r
-
P_To_Y
@NotNull @Contract(pure=true) @NotNull Number P_To_Y(@NotNull @NotNull Number θ, @NotNull @NotNull Number Half_Circle)
Convert Polar to Rectangle Coordinates- Parameters:
\u03b8
- angleHalf_Circle
- 180 for deg, 200 for gra, pi for rad- Returns:
- y = sin (θ) × r
-
R_To_R
@NotNull @Contract(pure=true) @NotNull Number R_To_R(@NotNull @NotNull Number y)
Convert Rectangle to Polar Coordinates- Parameters:
y
- y position- Returns:
- r = √(x²+y²)
-
R_To_θ
@NotNull @Contract(pure=true) @NotNull Number R_To_θ(@NotNull @NotNull Number y)
Convert Rectangle to Polar Coordinates- Parameters:
y
- y position- Returns:
- θ = arctan (y÷x)
-
R_To_θ
@NotNull @Contract(pure=true) @NotNull Number R_To_θ(@NotNull @NotNull Number y, @NotNull @NotNull Number Half_Circle)
Convert Rectangle to Polar Coordinates- Parameters:
y
- y positionHalf_Circle
- 180 for deg, 200 for gra, pi for rad- Returns:
- θ = arctan (y÷x)
-
root
@NotNull @Contract(pure=true) @NotNull Number root(@NotNull @NotNull Number r)
r√x- Parameters:
r
- root- Returns:
- e(loge x ÷ r)
-
Round
@NotNull @Contract(pure=true) @NotNull Number Round()
Round to effective Precision and Exponent.- Returns:
- rounded value
-
Round
@NotNull @Contract(pure=true) @NotNull Number Round(int Precision, int Exponent)
Round to a given Precision and Exponent.- Parameters:
Precision
- Total precisonExponent
- max exponent- Returns:
- rounded value
-
sin
@NotNull @Contract(pure=true) @NotNull Number sin()
sine- Returns:
- sin (x)
-
sin
@NotNull @Contract(pure=true) @NotNull Number sin(@NotNull @NotNull Number Half_Circle)
sine- Parameters:
Half_Circle
- value for a half circle- Returns:
- sin (x × π ÷ Half_Circle)
-
sin_hyp
@NotNull @Contract(pure=true) @NotNull Number sin_hyp()
hyperbolic sine: (ex - e-x) ÷ 2- Returns:
- Hyperbolic sine.
-
square
@NotNull @Contract(pure=true) @NotNull Number square()
x2- Returns:
- x2
-
square_root
@NotNull @Contract(pure=true) @NotNull Number square_root()
2√x- Returns:
- 2√x
-
tan
@NotNull @Contract(pure=true) @NotNull Number tan()
tan x- Returns:
- tan (x × π ÷ Half_Circle)
-
tan
@NotNull @Contract(pure=true) @NotNull Number tan(@NotNull @NotNull Number Half_Circle)
tangent- Parameters:
Half_Circle
- value for a half circle- Returns:
- tangent
-
tan_hyp
@NotNull @Contract(pure=true) @NotNull Number tan_hyp()
Hyperbolic tangent: (e2x - 1) ÷ (e2x + 1)- Returns:
- Hyperbolic tangent.
-
To_Debug_String
@NotNull @NotNull String To_Debug_String()
convert to native/debug string representation- Returns:
- format depends on type.
-
To_Integer
int To_Integer()
Convert to integerDo not mix up with Integer - This version returns a Java int!
- Returns:
- value as java int
-
To_Long
long To_Long()
Convert to long integerDo not mix up with Integer - This version returns a Java int!
- Returns:
- value as java int
-
toString
@NotNull @NotNull String toString()
display as human readable string. Same format as used by string conversion constructor- Overrides:
toString
in classObject
- Returns:
- string representation
- See Also:
Object.toString()
-
-