public class Fraction extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Fraction.FractionBuilder |
Constructor and Description |
---|
Fraction(UInt64 numerator,
UInt64 denominator) |
Modifier and Type | Method and Description |
---|---|
BigDecimal |
asBigDecimal(int precision)
Get the fraction as a
BigDecimal value with the specified amount of precision i.e. |
BigDecimal |
asBigDecimal(int precision,
RoundingMode roundingMode)
Get the fraction as a
BigDecimal value with the specified amount of precision i.e. |
double |
asDouble()
Get the fraction as a floating point value.
|
static Fraction.FractionBuilder |
builder() |
protected boolean |
canEqual(Object other) |
boolean |
equals(Object o) |
static Fraction |
from(long num,
long den) |
static Fraction |
from(Ratio value) |
UInt64 |
getDenominator()
The denominator of the fraction.
|
UInt64 |
getNumerator()
The numerator of the fraction.
|
int |
hashCode() |
String |
toString() |
public static Fraction from(Ratio value)
public static Fraction from(long num, long den)
public double asDouble()
public BigDecimal asBigDecimal(int precision)
BigDecimal
value with the specified amount of precision i.e. the specified amount of decimal points.
Result is rounded using RoundingMode.HALF_UP
precision
- how many decimals of precision.BigDecimal
.public BigDecimal asBigDecimal(int precision, RoundingMode roundingMode)
BigDecimal
value with the specified amount of precision i.e. the specified amount of decimal points.
Result is rounded using the provided RoundingMode
.precision
- how many decimals of precision.roundingMode
- the RoundingMode
to use.BigDecimal
.public static Fraction.FractionBuilder builder()
protected boolean canEqual(Object other)
public UInt64 getNumerator()
public UInt64 getDenominator()
Copyright © 2025. All rights reserved.