Package ghidra.pcode.floatformat
Class FloatFormat
java.lang.Object
ghidra.pcode.floatformat.FloatFormat
FloatFormat
provides IEEE 754 floating-point encoding formats in support of
floating-point data types and floating-point emulation. A combination of Java
float/double and BigFloat
are used to facilitate floating-point operations.-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptiondecodeBigFloat
(long encoding) Decodeencoding
to a BigFloat using this format.decodeBigFloat
(BigInteger encoding) double
decodeHostFloat
(long encoding) getBigFloat
(double d) getBigFloat
(float f) getBigFloat
(String string) Constructs aBigFloat
initialized to the value represented by the specified decimalString
, as performed byBigDecimal(String)
.getBigFloat
(BigDecimal value) Constructs aBigFloat
initialized to the value represented by the specifiedBigDecimal
.getBigFloat
(BigInteger value) getBigInfinity
(boolean sgn) getBigInfinityEncoding
(boolean sgn) getBigNaN
(boolean sgn) getBigNaNEncoding
(boolean sgn) getBigZero
(boolean sgn) getBigZeroEncoding
(boolean sgn) long
getEncoding
(double host) getEncoding
(BigFloat value) long
getInfinityEncoding
(boolean sgn) Get the maximum finiteBigFloat
value for this formatGet the minimum finite subnormalBigFloat
value for this formatlong
getNaNEncoding
(boolean sgn) int
getSize()
long
getZeroEncoding
(boolean sgn) long
opAbs
(long a) opAbs
(BigInteger a) long
opAdd
(long a, long b) opAdd
(BigInteger a, BigInteger b) long
opCeil
(long a) opCeil
(BigInteger a) long
opDiv
(long a, long b) opDiv
(BigInteger a, BigInteger b) long
opEqual
(long a, long b) opEqual
(BigInteger a, BigInteger b) long
opFloat2Float
(long a, FloatFormat outformat) opFloat2Float
(BigInteger a, FloatFormat outformat) long
opFloor
(long a) long
opInt2Float
(long a, int sizein) opInt2Float
(BigInteger a, int sizein, boolean signed) long
opLess
(long a, long b) opLess
(BigInteger a, BigInteger b) long
opLessEqual
(long a, long b) opLessEqual
(BigInteger a, BigInteger b) long
opMult
(long a, long b) opMult
(BigInteger a, BigInteger b) long
opNan
(long a) opNan
(BigInteger a) long
opNeg
(long a) opNeg
(BigInteger a) long
opNotEqual
(long a, long b) opNotEqual
(BigInteger a, BigInteger b) long
opRound
(long a) long
opSqrt
(long a) opSqrt
(BigInteger a) long
opSub
(long a, long b) opSub
(BigInteger a, BigInteger b) long
opTrunc
(long a, int sizeout) opTrunc
(BigInteger a, int sizeout) RoundbigFloat
using this format's displayContext.static BigFloat
toBigFloat
(double d) Convert a native double toBigFloat
using 8-byte IEEE 754 encodingstatic BigFloat
toBigFloat
(float f) Convert a native float toBigFloat
using 4-byte IEEE 754 encodingtoDecimalString
(BigFloat bigFloat) Perform appropriate rounding and conversion to BigDecimal prior to generating a formatted decimal string of the specified BigFloat value.toDecimalString
(BigFloat bigFloat, boolean compact) Perform appropriate rounding and conversion to BigDecimal prior to generating a formatted decimal string of the specified BigFloat value.
-
Field Details
-
maxValue
A constant holding the largest positive finite value -
minValue
A constant holding the smallest positive normal value
-
-
Method Details
-
getSize
public int getSize() -
getMaxBigFloat
Get the maximum finiteBigFloat
value for this format- Returns:
- maximum finite
BigFloat
value
-
getMinBigFloat
Get the minimum finite subnormalBigFloat
value for this format- Returns:
- minimum finite subnormal
BigFloat
value
-
getZeroEncoding
public long getZeroEncoding(boolean sgn) -
getInfinityEncoding
public long getInfinityEncoding(boolean sgn) -
getBigZeroEncoding
-
getBigZero
-
getBigInfinityEncoding
-
getBigInfinity
-
getNaNEncoding
public long getNaNEncoding(boolean sgn) -
getBigNaNEncoding
-
getBigNaN
-
getBigFloat
-
getBigFloat
-
decodeBigFloat
Decodeencoding
to a BigFloat using this format. The methoddecodeBigFloat(BigInteger)
should be used for encodings larger than 8 bytes.- Parameters:
encoding
- the encoding- Returns:
- the decoded value as a BigFloat
-
decodeHostFloat
public double decodeHostFloat(long encoding) -
decodeBigFloat
-
getEncoding
public long getEncoding(double host) -
getEncoding
-
round
RoundbigFloat
using this format's displayContext.- Parameters:
bigFloat
- any BigFloat- Returns:
- a BigDecimal rounded according to this format's displayContext
-
toDecimalString
Perform appropriate rounding and conversion to BigDecimal prior to generating a formatted decimal string of the specified BigFloat value.- Parameters:
bigFloat
- value- Returns:
- decimal string representation
-
toDecimalString
Perform appropriate rounding and conversion to BigDecimal prior to generating a formatted decimal string of the specified BigFloat value.- Parameters:
bigFloat
- valuecompact
- if true the precision will be reduced to a form which is still equivalent at the binary encoding level for this format. Enabling this will incur additional overhead.- Returns:
- decimal string representation
-
toBigFloat
Convert a native float toBigFloat
using 4-byte IEEE 754 encoding- Parameters:
f
- a float- Returns:
BigFloat
equal tof
-
toBigFloat
Convert a native double toBigFloat
using 8-byte IEEE 754 encoding- Parameters:
d
- a double- Returns:
BigFloat
equal tof
-
opEqual
public long opEqual(long a, long b) -
opEqual
-
opNotEqual
public long opNotEqual(long a, long b) -
opNotEqual
-
opLess
public long opLess(long a, long b) -
opLess
-
opLessEqual
public long opLessEqual(long a, long b) -
opLessEqual
-
opNan
public long opNan(long a) -
opNan
-
opAdd
public long opAdd(long a, long b) -
opAdd
-
opSub
public long opSub(long a, long b) -
opSub
-
opDiv
public long opDiv(long a, long b) -
opDiv
-
opMult
public long opMult(long a, long b) -
opMult
-
opNeg
public long opNeg(long a) -
opNeg
-
opAbs
public long opAbs(long a) -
opAbs
-
opSqrt
public long opSqrt(long a) -
opSqrt
-
opInt2Float
public long opInt2Float(long a, int sizein) -
opInt2Float
-
opFloat2Float
-
opFloat2Float
-
opTrunc
public long opTrunc(long a, int sizeout) -
opTrunc
-
opCeil
public long opCeil(long a) -
opCeil
-
opFloor
public long opFloor(long a) -
opFloor
-
opRound
public long opRound(long a) -
opRound
-
getBigFloat
-
getBigFloat
Constructs aBigFloat
initialized to the value represented by the specified decimalString
, as performed byBigDecimal(String)
. Other values permitted are (case-insenstive): "NaN", "Infinity", "+Infinity", "-Infinity" (SeeBigFloat.NAN
,BigFloat.INFINITY
,BigFloat.POSITIVE_INFINITY
,BigFloat.NEGATIVE_INFINITY
).- Parameters:
string
- the string to be parsed.- Returns:
- value as a
BigFloat
- Throws:
NullPointerException
- if the string is nullNumberFormatException
- if the string parse fails.
-
getBigFloat
Constructs aBigFloat
initialized to the value represented by the specifiedBigDecimal
.- Parameters:
value
- the decimal value.- Returns:
- value as a
BigFloat
- Throws:
NullPointerException
- if the string is nullNumberFormatException
- if the string parse fails.
-