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

Function decFloatCompare

extern/decNumber/decBasic.c:1677–1690  ·  view source on GitHub ↗

------------------------------------------------------------------ */ decFloatCompare -- compare two decFloats; quiet NaNs allowed */ / result gets the result of comparing dfl and dfr */ dfl is the first decFloat (lhs) */ dfr is the second decFloat (rhs) */ set is the context

Source from the content-addressed store, hash-verified

1675/* returns result, which may be -1, 0, 1, or NaN (Unordered) */
1676/* ------------------------------------------------------------------ */
1677decFloat * decFloatCompare(decFloat *result,
1678 const decFloat *dfl, const decFloat *dfr,
1679 decContext *set) {
1680 Int comp; // work
1681 // NaNs are handled as usual
1682 if (DFISNAN(dfl) || DFISNAN(dfr)) return decNaNs(result, dfl, dfr, set);
1683 // numeric comparison needed
1684 comp=decNumCompare(dfl, dfr, 0);
1685 decFloatZero(result);
1686 if (comp==0) return result;
1687 DFBYTE(result, DECBYTES-1)=0x01; // LSD=1
1688 if (comp<0) DFBYTE(result, 0)|=0x80; // set sign bit
1689 return result;
1690 } // decFloatCompare
1691
1692/* ------------------------------------------------------------------ */
1693/* decFloatCompareSignal -- compare two decFloats; all NaNs signal */

Callers

nothing calls this directly

Calls 3

decNumCompareFunction · 0.85
decFloatZeroFunction · 0.85
decNaNsFunction · 0.70

Tested by

no test coverage detected