Class BCDFraction
- java.lang.Object
-
- net.sourceforge.uiq3.math.BCDFraction
-
-
Field Summary
Fields Modifier and Type Field Description static @NotNull BCDFractionApprox_ee approximation used for unit testsstatic @NotNull BCDFractionApprox_ππ approximation used for unit testsprivate @NotNull BCDIntegerDenominatorThe Denominator:private static LoggerLoggerClass logger instance.static @NotNull BCDFractionNum_00static @NotNull BCDFractionNum_11static @NotNull BCDFractionNum_180180static @NotNull BCDFractionNum_22static @NotNull BCDFractionNum_200200private @NotNull BCDIntegerNumeratorThe Numerator:private static StringTAGClass logger tag.private static PatternValues_2matches «2/3»private static PatternValues_3matches «1 2/3»-
Fields inherited from interface net.sourceforge.uiq3.math.Number
Compare_Equal, Compare_Greater, Compare_Less, Effective_Precision, Max_Precision
-
-
Constructor Summary
Constructors Constructor Description BCDFraction(long Whole)create new fractionBCDFraction(long Whole, long Numerator, long Denominator)create new fractionBCDFraction(@NotNull String Text)create new fraction from a stringBCDFraction(@NotNull BCDFraction Value)create new fractionBCDFraction(@NotNull BCDInteger Whole)create new fractionBCDFraction(@NotNull BCDInteger Numerator, @NotNull BCDInteger Denominator)create new fractionBCDFraction(@NotNull Number Whole, @NotNull Number Numerator, @NotNull BCDInteger Denominator)create new fraction
-
Method Summary
All Methods Instance Methods Concrete 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 BCDIntegera()Fraktur represented as «a b/c»@NotNull Numberabs()|x|@NotNull Numberand(@NotNull Number y)Logical and@NotNull Numberarc_cos()arc cosine@NotNull Numberarc_cos(@NotNull Number Half_Circle)arc cosine@NotNull Numberarc_cos_hyp()area hyperbolic cosine: loge (x + √(x-1) × √(x+1))@NotNull Numberarc_sin()arc sine@NotNull Numberarc_sin(@NotNull Number Half_Circle)arc sine@NotNull Numberarc_sin_hyp()area hyperbolic sine: loge (x + √(x² + 1))@NotNull Numberarc_tan()arc tangent@NotNull Numberarc_tan(@NotNull Number Half_Circle)arc tangent@NotNull Numberarc_tan_hyp()area hyperbolic tangent: loge ((1 + x) ÷ (1 - x)) / 2@NotNull BCDFloatAs_BCDFloat()Either convert to a BCDFloat or return this.@NotNull BCDFractionAs_BCDFraction()Either convert to a or return this.@NotNull BCDIntegerAs_BCDInteger()Either convert to a BCDInteger or return this.@NotNull BCDIntegerb()Fraktur represented as «a b/c»@NotNull BCDIntegerc()Fraktur represented as «a b/c» or «d/c»@NotNull Objectclone()clone the float - but it might be easier to use the provided copy Constructor instead.@NotNull NumberClone()clone the float - but it might be easier to use the provided copy Constructor instead.longCoefficient_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.intCompare(@NotNull Number Value)Compare valuesintcompareTo(@NotNull Number rightValue)@NotNull Numbercos()cos (x)@NotNull Numbercos(@NotNull Number Half_Circle)cosine@NotNull Numbercos_hyp()Hyperbolic cosine: (Exponent^x + Exponent^-x)/2@NotNull BCDIntegerd()Fraktur represented as «d/c».byte[]Digits()number: sum(i = 0 ...booleanequals(@NotNull Object rightValue)@NotNull Numberexp_10()10x@NotNull Numberexp_e()exintExponent()current exponent - note that the exponent is based on the internal representation where the radix point is right most.@NotNull NumberFix(int Decimal, int Exponent)Round to a given Precision after the decimal point.@NotNull NumberFrac()Recompose a frac double from the given data.inthashCode()intIndirect_Value(int Digit_Count)Get valuef or indirect addressing.@NotNull NumberInteger()integer part of the BCDFloatbooleanIs_Finite()current value is a normal numberbooleanIs_Infinite()current value is Infinity (but not N/A).booleanIs_Integer()Current value is integer value.booleanIs_NaN()current value is not a numberbooleanIs_Negative()Current value us negativebooleanIs_Zero()value is 0@NotNull Numberlog_10()log10 (x)@NotNull Numberlog_e()loge (x)@NotNull Numberneg()voidNormalize()normalize the value@NotNull Numbernot()Logical notintNum_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 Numberor(@NotNull Number y)Logical or@NotNull NumberP_To_X(@NotNull Number θ)Convert Polar to Rectangle Coordinates@NotNull NumberP_To_X(@NotNull Number θ, @NotNull Number Half_Circle)Convert Polar to Rectangle Coordinates@NotNull NumberP_To_Y(@NotNull Number θ)Convert Polar to Rectangle Coordinates@NotNull NumberP_To_Y(@NotNull Number θ, @NotNull Number Half_Circle)Convert Polar to Rectangle Coordinates@NotNull NumberR_To_R(@NotNull Number y)Convert Rectangle to Polar Coordinates@NotNull NumberR_To_θ(@NotNull Number y)Convert Rectangle to Polar Coordinates@NotNull NumberR_To_θ(@NotNull Number y, @NotNull Number Half_Circle)Convert Rectangle to Polar Coordinates@NotNull Numberroot(@NotNull Number r)r√x@NotNull NumberRound()Round to effective Precision and Exponent.@NotNull NumberRound(int Precision, int Exponent)Round to a given Precision and Exponent.@NotNull Numbersin()sine@NotNull Numbersin(@NotNull Number Half_Circle)sine@NotNull Numbersin_hyp()hyperbolic sine: (ex - e-x) ÷ 2@NotNull Numbersquare()x2@NotNull Numbersquare_root()2√x@NotNull Numbertan()tan x@NotNull Numbertan(@NotNull Number Half_Circle)tangent@NotNull Numbertan_hyp()Hyperbolic tangent: (e2x - 1) ÷ (e2x + 1)@NotNull StringTo_Debug_String()convert to native/debug string representationintTo_Integer()Convert to integerlongTo_Long()Convert to long integer@NotNull StringtoString()display as debug string@NotNull Numberxor(@NotNull Number y)Logical xor
-
-
-
Field Detail
-
Logger
private static final Logger Logger
Class logger instance.
-
TAG
private static final String TAG
Class logger tag.
-
Values_2
private static final Pattern Values_2
matches «2/3»
-
Values_3
private static final Pattern Values_3
matches «1 2/3»
-
Approx_e
@NotNull public static final @NotNull BCDFraction Approx_e
e approximation used for unit tests
-
Approx_π
@NotNull public static final @NotNull BCDFraction Approx_π
π approximation used for unit tests
-
Num_0
@NotNull public static final @NotNull BCDFraction Num_0
0
-
Num_1
@NotNull public static final @NotNull BCDFraction Num_1
1
-
Num_180
@NotNull public static final @NotNull BCDFraction Num_180
180
-
Num_2
@NotNull public static final @NotNull BCDFraction Num_2
2
-
Num_200
@NotNull public static final @NotNull BCDFraction Num_200
200
-
Denominator
@NotNull private @NotNull BCDInteger Denominator
The Denominator:
Whole + Numerator / Denominator
-
Numerator
@NotNull private @NotNull BCDInteger Numerator
The Numerator:
Numerator / Denominator
-
-
Constructor Detail
-
BCDFraction
public BCDFraction(@NotNull @NotNull BCDFraction Value)create new fraction
- Parameters:
Value- value to copy
-
BCDFraction
public BCDFraction(@NotNull @NotNull BCDInteger Whole)create new fraction
- Parameters:
Whole- The whole part of the number
-
BCDFraction
public BCDFraction(@NotNull @NotNull BCDInteger Numerator, @NotNull @NotNull BCDInteger Denominator)create new fraction
- Parameters:
Numerator- The numeratorDenominator- The denominator
-
BCDFraction
public BCDFraction(long Whole)
create new fraction
- Parameters:
Whole- The whole part of the number
-
BCDFraction
public BCDFraction(long Whole, long Numerator, long Denominator)create new fraction
- Parameters:
Whole- The whole part of the numberNumerator- The numeratorDenominator- The denominator
-
BCDFraction
public BCDFraction(@NotNull @NotNull Number Whole, @NotNull @NotNull Number Numerator, @NotNull @NotNull BCDInteger Denominator)create new fraction
- Parameters:
Whole- The whole part of the numberNumerator- The numeratorDenominator- The denominator
-
BCDFraction
public BCDFraction(@NotNull @NotNull String Text)create new fraction from a string
- Parameters:
Text- A String of the type "999" or “999/999” or "999 999/999"
-
-
Method Detail
-
$minus
@Contract(pure=true) @NotNull public @NotNull Number $minus(@NotNull @NotNull Number y)
x - y
-
$times
@Contract(pure=true) @NotNull public @NotNull Number $times(@NotNull @NotNull Number y)
x × y
-
$times$times
@Contract(pure=true) @NotNull public @NotNull Number $times$times(@NotNull @NotNull Number y) throws BCDError
xy- Specified by:
$times$timesin interfaceNumber- Parameters:
y- power- Returns:
- xy
- Throws:
BCDError- calculation error
-
As_BCDFloat
@NotNull public @NotNull BCDFloat As_BCDFloat()
Either convert to a BCDFloat or return this.
- Specified by:
As_BCDFloatin interfaceNumber- Returns:
- value as java int
-
As_BCDFraction
@NotNull public @NotNull BCDFraction As_BCDFraction()
Either convert to a or return this.
- Specified by:
As_BCDFractionin interfaceNumber- Returns:
- value as java int
-
As_BCDInteger
@NotNull public @NotNull BCDInteger As_BCDInteger()
Either convert to a BCDInteger or return this.
- Specified by:
As_BCDIntegerin interfaceNumber- Returns:
- value as java int
-
Clone
@NotNull public @NotNull Number Clone()
clone the float - but it might be easier to use the provided copy Constructor instead.- Specified by:
Clonein interfaceNumber- Returns:
- a new BCDFloat from an existing one.
- See Also:
Object.clone()
-
Coefficient_As_Long
public long Coefficient_As_Long() throws BCDErrorcoefficient - 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.
- Specified by:
Coefficient_As_Longin interfaceNumber- Returns:
- Coefficient
- Throws:
BCDError- when it's not a normal number
-
Compare
public int Compare(@NotNull @NotNull Number Value)Compare values
-
Digits
public byte[] Digits()
number: sum(i = 0 ... Num_Digits-1; Digits[i]*10^i)
-
Exponent
public int Exponent() throws BCDErrorcurrent exponent - note that the exponent is based on the internal representation where the radix point is right most. For example π is 314159265358979324×10-17.
-
Fix
@NotNull public @NotNull Number Fix(int Decimal, int Exponent)
Round to a given Precision after the decimal point.
-
Frac
@NotNull public @NotNull Number Frac()
Recompose a frac double from the given data.
-
Indirect_Value
public int Indirect_Value(int Digit_Count)
Get valuef or indirect addressing.
- Specified by:
Indirect_Valuein interfaceNumber- 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 public @NotNull Number Integer()
integer part of the BCDFloat
Do not mix up with To_Integer - This version returns another BCDFloat!
-
Is_Finite
public boolean Is_Finite()
current value is a normal number
-
Is_Infinite
public boolean Is_Infinite()
current value is Infinity (but not N/A).- Specified by:
Is_Infinitein interfaceNumber- Returns:
- true when x is infinite
-
Is_Integer
public boolean Is_Integer()
Current value is integer value.- Specified by:
Is_Integerin interfaceNumber- Returns:
- true when x is an integer number
-
Is_NaN
public boolean Is_NaN()
current value is not a number
-
Is_Negative
public boolean Is_Negative()
Current value us negative- Specified by:
Is_Negativein interfaceNumber- Returns:
- true when x <= -0
-
Is_Zero
public boolean Is_Zero()
value is 0
-
Normalize
public void Normalize()
normalize the value
depending on type: remove leading zeros and / or trailing zeros
-
Num_Digits
public int Num_Digits() throws BCDErrorthe current number of digits - not that when the number is not normalised there might be more 0's in the number then strictly needed.- Specified by:
Num_Digitsin interfaceNumber- Returns:
- number of digits
- Throws:
BCDError
-
P_To_X
@Contract(pure=true) @NotNull public @NotNull Number P_To_X(@NotNull @NotNull Number θ)
Convert Polar to Rectangle Coordinates
-
P_To_X
@Contract(pure=true) @NotNull public @NotNull Number P_To_X(@NotNull @NotNull Number θ, @NotNull @NotNull Number Half_Circle)
Convert Polar to Rectangle Coordinates
-
P_To_Y
@Contract(pure=true) @NotNull public @NotNull Number P_To_Y(@NotNull @NotNull Number θ)
Convert Polar to Rectangle Coordinates
-
P_To_Y
@Contract(pure=true) @NotNull public @NotNull Number P_To_Y(@NotNull @NotNull Number θ, @NotNull @NotNull Number Half_Circle)
Convert Polar to Rectangle Coordinates
-
R_To_R
@Contract(pure=true) @NotNull public @NotNull Number R_To_R(@NotNull @NotNull Number y)
Convert Rectangle to Polar Coordinates
-
R_To_θ
@Contract(pure=true) @NotNull public @NotNull Number R_To_θ(@NotNull @NotNull Number y)
Convert Rectangle to Polar Coordinates
-
R_To_θ
@Contract(pure=true) @NotNull public @NotNull Number R_To_θ(@NotNull @NotNull Number y, @NotNull @NotNull Number Half_Circle)
Convert Rectangle to Polar Coordinates
-
Round
@NotNull public @NotNull Number Round()
Round to effective Precision and Exponent.
-
Round
@NotNull public @NotNull Number Round(int Precision, int Exponent)
Round to a given Precision and Exponent.
-
To_Debug_String
@NotNull public @NotNull String To_Debug_String()
convert to native/debug string representation- Specified by:
To_Debug_Stringin interfaceNumber- Returns:
- (Coefficient, Exponent)
-
To_Integer
public int To_Integer()
Convert to integer Do not mix up with Integer - This version returns a Java int!- Specified by:
To_Integerin interfaceNumber- Returns:
- value as java int
-
To_Long
public long To_Long()
Convert to long integer Do not mix up with Integer - This version returns a Java int!
-
a
@NotNull public @NotNull BCDInteger a()
Fraktur represented as «a b/c»
- Returns:
- a
-
abs
@Contract(pure=true) @NotNull public @NotNull Number abs()
|x|
-
and
@Contract(pure=true) @NotNull public @NotNull Number and(@NotNull @NotNull Number y)
Logical and
-
arc_cos
@Contract(pure=true) @NotNull public @NotNull Number arc_cos()
arc cosine
-
arc_cos
@Contract(pure=true) @NotNull public @NotNull Number arc_cos(@NotNull @NotNull Number Half_Circle)
arc cosine
-
arc_cos_hyp
@Contract(pure=true) @NotNull public @NotNull Number arc_cos_hyp()
area hyperbolic cosine: loge (x + √(x-1) × √(x+1))- Specified by:
arc_cos_hypin interfaceNumber- Returns:
- Hyperbolic sine.
-
arc_sin
@Contract(pure=true) @NotNull public @NotNull Number arc_sin()
arc sine
-
arc_sin
@Contract(pure=true) @NotNull public @NotNull Number arc_sin(@NotNull @NotNull Number Half_Circle)
arc sine
-
arc_sin_hyp
@Contract(pure=true) @NotNull public @NotNull Number arc_sin_hyp()
area hyperbolic sine: loge (x + √(x² + 1))- Specified by:
arc_sin_hypin interfaceNumber- Returns:
- Hyperbolic sine.
-
arc_tan
@Contract(pure=true) @NotNull public @NotNull Number arc_tan()
arc tangent
-
arc_tan
@Contract(pure=true) @NotNull public @NotNull Number arc_tan(@NotNull @NotNull Number Half_Circle)
arc tangent
-
arc_tan_hyp
@Contract(pure=true) @NotNull public @NotNull Number arc_tan_hyp()
area hyperbolic tangent: loge ((1 + x) ÷ (1 - x)) / 2- Specified by:
arc_tan_hypin interfaceNumber- Returns:
- Hyperbolic sine.
-
b
@NotNull public @NotNull BCDInteger b()
Fraktur represented as «a b/c»
- Returns:
- b
-
c
@NotNull public @NotNull BCDInteger c()
Fraktur represented as «a b/c» or «d/c»
- Returns:
- c
-
clone
@NotNull public @NotNull Object clone() throws CloneNotSupportedException
clone the float - but it might be easier to use the provided copy Constructor instead.- Overrides:
clonein classObject- Returns:
- a new BCDInteger from an existing one.
- Throws:
CloneNotSupportedException- See Also:
Object.clone()
-
compareTo
public int compareTo(@NotNull @NotNull Number rightValue)- Specified by:
compareToin interfaceComparable<Number>- Specified by:
compareToin interfaceNumber- 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
@Contract(pure=true) @NotNull public @NotNull Number cos()
cos (x)
-
cos
@Contract(pure=true) @NotNull public @NotNull Number cos(@NotNull @NotNull Number Half_Circle)
cosine
-
cos_hyp
@Contract(pure=true) @NotNull public @NotNull Number cos_hyp()
Hyperbolic cosine: (Exponent^x + Exponent^-x)/2
-
d
@NotNull public @NotNull BCDInteger d()
Fraktur represented as «d/c».
- Returns:
- d
-
equals
public boolean equals(@NotNull @NotNull Object rightValue)
-
exp_e
@Contract(pure=true) @NotNull public @NotNull Number exp_e()
ex
-
log_10
@Contract(pure=true) @NotNull public @NotNull Number log_10()
log10 (x)
-
log_e
@Contract(pure=true) @NotNull public @NotNull Number log_e()
loge (x)
-
neg
@Contract(pure=true) @NotNull public @NotNull Number neg()
-
not
@Contract(pure=true) @NotNull public @NotNull Number not()
Logical not
-
sin
@Contract(pure=true) @NotNull public @NotNull Number sin()
sine
-
sin
@Contract(pure=true) @NotNull public @NotNull Number sin(@NotNull @NotNull Number Half_Circle)
sine
-
sin_hyp
@Contract(pure=true) @NotNull public @NotNull Number sin_hyp()
hyperbolic sine: (ex - e-x) ÷ 2
-
square
@Contract(pure=true) @NotNull public @NotNull Number square()
x2
-
square_root
@Contract(pure=true) @NotNull public @NotNull Number square_root()
2√x- Specified by:
square_rootin interfaceNumber- Returns:
- 2√x
-
tan
@Contract(pure=true) @NotNull public @NotNull Number tan()
tan x
-
tan
@Contract(pure=true) @NotNull public @NotNull Number tan(@NotNull @NotNull Number Half_Circle)
tangent
-
tan_hyp
@NotNull public @NotNull Number tan_hyp()
Hyperbolic tangent: (e2x - 1) ÷ (e2x + 1)
-
toString
@NotNull public @NotNull String toString()
display as debug string
- Specified by:
toStringin interfaceNumber- Overrides:
toStringin classObject- Returns:
- string representation
- See Also:
Object.toString()
-
-