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
Fields -
Method Summary
Modifier and TypeMethodDescriptiondecodeBigFloat(long encoding) Decodeencodingto a BigFloat using this format.decodeBigFloat(BigInteger encoding) doubledecodeHostFloat(long encoding) getBigFloat(double d) getBigFloat(float f) getBigFloat(String string) Constructs aBigFloatinitialized to the value represented by the specified decimalString, as performed byBigDecimal(String).getBigFloat(BigDecimal value) Constructs aBigFloatinitialized 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) longgetEncoding(double host) getEncoding(BigFloat value) longgetInfinityEncoding(boolean sgn) Get the maximum finiteBigFloatvalue for this formatGet the minimum finite subnormalBigFloatvalue for this formatlonggetNaNEncoding(boolean sgn) intgetSize()longgetZeroEncoding(boolean sgn) longopAbs(long a) opAbs(BigInteger a) longopAdd(long a, long b) opAdd(BigInteger a, BigInteger b) longopCeil(long a) opCeil(BigInteger a) longopDiv(long a, long b) opDiv(BigInteger a, BigInteger b) longopEqual(long a, long b) opEqual(BigInteger a, BigInteger b) longopFloat2Float(long a, FloatFormat outformat) opFloat2Float(BigInteger a, FloatFormat outformat) longopFloor(long a) longopInt2Float(long a, int sizein) opInt2Float(BigInteger a, int sizein, boolean signed) longopLess(long a, long b) opLess(BigInteger a, BigInteger b) longopLessEqual(long a, long b) opLessEqual(BigInteger a, BigInteger b) longopMult(long a, long b) opMult(BigInteger a, BigInteger b) longopNan(long a) opNan(BigInteger a) longopNeg(long a) opNeg(BigInteger a) longopNotEqual(long a, long b) opNotEqual(BigInteger a, BigInteger b) longopRound(long a) longopSqrt(long a) opSqrt(BigInteger a) longopSub(long a, long b) opSub(BigInteger a, BigInteger b) longopTrunc(long a, int sizeout) opTrunc(BigInteger a, int sizeout) RoundbigFloatusing this format's displayContext.static BigFloattoBigFloat(double d) Convert a native double toBigFloatusing 8-byte IEEE 754 encodingstatic BigFloattoBigFloat(float f) Convert a native float toBigFloatusing 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 finiteBigFloatvalue for this format- Returns:
- maximum finite
BigFloatvalue
-
getMinBigFloat
Get the minimum finite subnormalBigFloatvalue for this format- Returns:
- minimum finite subnormal
BigFloatvalue
-
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
Decodeencodingto 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
RoundbigFloatusing 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 toBigFloatusing 4-byte IEEE 754 encoding- Parameters:
f- a float- Returns:
BigFloatequal tof
-
toBigFloat
Convert a native double toBigFloatusing 8-byte IEEE 754 encoding- Parameters:
d- a double- Returns:
BigFloatequal 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 aBigFloatinitialized 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 aBigFloatinitialized 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.
-