Package ghidra.pcode.floatformat
Class BigFloat
java.lang.Object
ghidra.pcode.floatformat.BigFloat
- All Implemented Interfaces:
- Comparable<BigFloat>
An IEEE 754 floating point class.
 
Values represented:
- QUIET_NAN, SIGNALED_NAN
- -INF, +INF
- value = sign * unscaled * 2 ^ (scale-fracbits)
Operations compute exact result then round to nearest even.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final BigDecimalstatic final BigDecimalstatic final Stringstatic final Stringstatic final Stringstatic final String
- 
Method SummaryModifier and TypeMethodDescriptionvoidabs()this=abs(this)static BigFloatvoidthis+=otherstatic BigFloatprotected voidvoidceil()this=ceil(this)static BigFloatintcopy()protected voidvoidthis/=otherstatic BigFloatbooleanvoidfloor()this=floor(this)static BigFloatprotected intinthashCode()static BigFloatinfinity(int fracbits, int expbits, int sign) protected voidinternalRound(boolean eps) This function is used internally to round after a computation.booleanDetermine if the state of this BigFloat reflects a subnormal/denormal value.booleanbooleanisNaN()booleanisNormal()Determine if the state of this BigFloat reflects a normalized value.booleanisZero()protected voidprotected voidprotected voidmakeZero()voidthis*=otherstatic BigFloatvoidnegate()this*=-1static BigFloatstatic BigFloatquietNaN(int fracbits, int expbits, int sign) Return the BigFloat with the given number of bits representing (quiet) NaN.voidround()Round this value to the nearest whole numberstatic BigFloatprotected voidscaleUpTo(int newLength) voidsqrt()this=sqrt(this)static BigFloatvoidthis-=otherstatic BigFloatprotected voidIf finite, the returned BigDecimal is exactly equal to this.toString()Perform rounding and conversion to BigDecimal prior to generating a formatted decimal string of the specified BigFloat value.toString(FloatFormat ff, boolean compact) Perform appropriate rounding and conversion to BigDecimal prior to generating a formatted decimal string of the specified BigFloat value.toString(MathContext displayContext) Perform rounding and conversion to BigDecimal prior to generating a formatted decimal string of the specified BigFloat value.voidtrunc()this=trunc(this)(round toward zero)static BigFloatstatic BigFloatzero(int fracbits, int expbits) Return the BigFloat with the given number of bits representing (positive) zero.static BigFloatzero(int fracbits, int expbits, int sign) Return the BigFloat with the given number of bits representing zero.
- 
Field Details- 
INFINITY- See Also:
 
- 
POSITIVE_INFINITY- See Also:
 
- 
NEGATIVE_INFINITY- See Also:
 
- 
NAN- See Also:
 
- 
BIG_POSITIVE_INFINITY
- 
BIG_NEGATIVE_INFINITY
 
- 
- 
Method Details- 
hashCodepublic int hashCode()
- 
equals
- 
zeroReturn the BigFloat with the given number of bits representing zero.- Parameters:
- fracbits- number of fractional bits
- expbits- number of bits in the exponent
- sign- +1 or -1
- Returns:
- a BigFloat representing +zero or -zero
 
- 
zeroReturn the BigFloat with the given number of bits representing (positive) zero.- Parameters:
- fracbits- number of fractional bits
- expbits- number of bits in the exponent
- Returns:
- a BigFloat representing +zero
 
- 
infinity- Parameters:
- fracbits- number of fractional bits
- expbits- number of bits in the exponent
- sign- +1 or -1
- Returns:
- +inf or -inf
 
- 
quietNaNReturn the BigFloat with the given number of bits representing (quiet) NaN.- Parameters:
- fracbits- number of fractional bits
- expbits- number of bits in the exponent
- sign- +1 or -1
- Returns:
- a BigFloat representing (quiet) NaN
 
- 
scaleUpToprotected void scaleUpTo(int newLength) 
- 
isNormalpublic boolean isNormal()Determine if the state of this BigFloat reflects a normalized value.NOTE: This method relies on the manner of construction and only checks for FloatKind.FINITEand that full size of the fractional bits is used for the unscaled value.- Returns:
- trueif this BigFloat is FINITE and normal.
 
- 
isDenormalpublic boolean isDenormal()Determine if the state of this BigFloat reflects a subnormal/denormal value.NOTE: This method relies on the manner of construction and only checks for FloatKind.FINITEand that the non-zero unscaled valued does not use all fractional bits.- Returns:
- trueif this BigFloat is FINITE and denormal
 
- 
internalRoundprotected void internalRound(boolean eps) This function is used internally to round after a computation.Assume that the true value is sign * (unscaled + eps) * 2 ^ (scale-fracbits) and unscaled.bitLength() > fracbits+1 (or the value is subnormal with at least 1 bit of extra precision) - Parameters:
- eps- < 1
 
- 
getLeadBitPosprotected int getLeadBitPos()
- 
toBigDecimalIf finite, the returned BigDecimal is exactly equal to this. If not finite, one of the FloatFormat.BIG_* constants is returned.- Returns:
- a BigDecimal or null if value is NaN (i.e., FloatKind.QUIET_NANorFloatKind.SIGNALING_NAN).
 
- 
toBinaryString
- 
makeSignalingNaNprotected void makeSignalingNaN()
- 
makeQuietNaNprotected void makeQuietNaN()
- 
isNaNpublic boolean isNaN()- Returns:
- trueif this BigFloat is NaN
 
- 
makeZeroprotected void makeZero()
- 
isInfinitepublic boolean isInfinite()- Returns:
- trueif this BigFloat is infinite
 
- 
isZeropublic boolean isZero()- Returns:
- trueif this BigFloat is zero
 
- 
copy- Returns:
- a copy of this BigFloat
 
- 
copyFrom
- 
div- Parameters:
- a- a BigFloat
- b- a BigFloat
- Returns:
- a/b
 
- 
divthis/=other- Parameters:
- other- a BigFloat
 
- 
mul- Parameters:
- a- a BigFloat
- b- a BigFloat
- Returns:
- a*b
 
- 
multhis*=other- Parameters:
- other- a BigFloat
 
- 
add- Parameters:
- a- a BigFloat
- b- a BigFloat
- Returns:
- a+b
 
- 
addthis+=other- Parameters:
- other- a BigFloat
 
- 
sub- Parameters:
- a- a BigFloat
- b- a BigFloat
- Returns:
- a-b
 
- 
subthis-=other- Parameters:
- other- a BigFloat
 
- 
add0
- 
sub0
- 
sqrt- Parameters:
- a- a BigFloat
- Returns:
- the square root of a
 
- 
sqrtpublic void sqrt()this=sqrt(this)Square root by abacus algorithm, Martin Guy @ UKC, June 1985. From a book on programming abaci by Mr C. Woo. Argument is a positive integer, as is result. adapted from http://medialab.freaknet.org/martin/src/sqrt/sqrt.c 
- 
floor- Parameters:
- a- a BigFloat
- Returns:
- floor(a)
 
- 
floorpublic void floor()this=floor(this)
- 
ceil- Parameters:
- a- a BigFloat
- Returns:
- ceil(a)
 
- 
ceilpublic void ceil()this=ceil(this)
- 
trunc- Parameters:
- a- a BigFloat
- Returns:
- trunc(a)(round toward zero)
 
- 
truncpublic void trunc()this=trunc(this)(round toward zero)
- 
negatepublic void negate()this*=-1
- 
negate- Parameters:
- a- a BigFloat
- Returns:
- -a
 
- 
abs- Parameters:
- a- a BigFloat
- Returns:
- abs(a)
 
- 
abspublic void abs()this=abs(this)
- 
toBigInteger- Returns:
- the truncated integer form of this BigFloat
 
- 
round- Parameters:
- a- a BigFloat
- Returns:
- round(a)
 
- 
roundpublic void round()Round this value to the nearest whole number
- 
compareTo- Specified by:
- compareToin interface- Comparable<BigFloat>
 
- 
toStringPerform rounding and conversion to BigDecimal prior to generating a formatted decimal string of the specified BigFloat value. A default generatedMathContextis used.
- 
toStringPerform rounding and conversion to BigDecimal prior to generating a formatted decimal string of the specified BigFloat value.- Parameters:
- displayContext- display context used for rounding and precision.
- Returns:
- decimal string representation
 
- 
toStringPerform appropriate rounding and conversion to BigDecimal prior to generating a formatted decimal string of the specified BigFloat value. SeetoString(FloatFormat, boolean),FloatFormat.toDecimalString(BigFloat)andFloatFormat.toDecimalString(BigFloat, boolean).- Parameters:
- ff- float format
- compact- if true the precision will be reduced to a form which is still equivalent at the binary encoding level for the specified FloatFormat.
- Returns:
- decimal string representation
 
 
-