MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / decFloatClass

Function decFloatClass

extern/decNumber/decBasic.c:1621–1645  ·  view source on GitHub ↗

------------------------------------------------------------------ */ decFloatClass -- return the class of a decFloat */ / df is the decFloat to test */ returns the decClass that df falls into */ ------------------------------------------------------------------ */

Source from the content-addressed store, hash-verified

1619/* returns the decClass that df falls into */
1620/* ------------------------------------------------------------------ */
1621enum decClass decFloatClass(const decFloat *df) {
1622 Int exp; // exponent
1623 if (DFISSPECIAL(df)) {
1624 if (DFISQNAN(df)) return DEC_CLASS_QNAN;
1625 if (DFISSNAN(df)) return DEC_CLASS_SNAN;
1626 // must be an infinity
1627 if (DFISSIGNED(df)) return DEC_CLASS_NEG_INF;
1628 return DEC_CLASS_POS_INF;
1629 }
1630 if (DFISZERO(df)) { // quite common
1631 if (DFISSIGNED(df)) return DEC_CLASS_NEG_ZERO;
1632 return DEC_CLASS_POS_ZERO;
1633 }
1634 // is finite and non-zero; similar code to decFloatIsNormal, here
1635 // [this could be speeded up slightly by in-lining decFloatDigits]
1636 exp=GETEXPUN(df) // get unbiased exponent ..
1637 +decFloatDigits(df)-1; // .. and make adjusted exponent
1638 if (exp>=DECEMIN) { // is normal
1639 if (DFISSIGNED(df)) return DEC_CLASS_NEG_NORMAL;
1640 return DEC_CLASS_POS_NORMAL;
1641 }
1642 // is subnormal
1643 if (DFISSIGNED(df)) return DEC_CLASS_NEG_SUBNORMAL;
1644 return DEC_CLASS_POS_SUBNORMAL;
1645 } // decFloatClass
1646
1647/* ------------------------------------------------------------------ */
1648/* decFloatClassString -- return the class of a decFloat as a string */

Callers 1

decFloatClassStringFunction · 0.85

Calls 1

decFloatDigitsFunction · 0.85

Tested by

no test coverage detected