------------------------------------------------------------------ */ decFloatClass -- return the class of a decFloat */ / df is the decFloat to test */ returns the decClass that df falls into */ ------------------------------------------------------------------ */
| 1619 | /* returns the decClass that df falls into */ |
| 1620 | /* ------------------------------------------------------------------ */ |
| 1621 | enum 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 */ |
no test coverage detected