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

Function decFloatLogB

extern/decNumber/decBasic.c:2475–2506  ·  view source on GitHub ↗

------------------------------------------------------------------ */ decFloatLogB -- return adjusted exponent, by 754 rules */ / result gets the adjusted exponent as an integer, or a NaN etc. */ df is the decFloat to be examined */ set is the context */ returns result

Source from the content-addressed store, hash-verified

2473/* NaNs are propagated as usual */
2474/* ------------------------------------------------------------------ */
2475decFloat * decFloatLogB(decFloat *result, const decFloat *df,
2476 decContext *set) {
2477 Int ae; // adjusted exponent
2478 if (DFISNAN(df)) return decNaNs(result, df, NULL, set);
2479 if (DFISINF(df)) {
2480 DFWORD(result, 0)=0; // need +ve
2481 return decInfinity(result, result); // canonical +Infinity
2482 }
2483 if (DFISZERO(df)) {
2484 set->status|=DEC_Division_by_zero; // as per 754
2485 DFWORD(result, 0)=DECFLOAT_Sign; // make negative
2486 return decInfinity(result, result); // canonical -Infinity
2487 }
2488 ae=GETEXPUN(df) // get unbiased exponent ..
2489 +decFloatDigits(df)-1; // .. and make adjusted exponent
2490 // ae has limited range (3 digits for DOUBLE and 4 for QUAD), so
2491 // it is worth using a special case of decFloatFromInt32
2492 DFWORD(result, 0)=ZEROWORD; // always
2493 if (ae<0) {
2494 DFWORD(result, 0)|=DECFLOAT_Sign; // -0 so far
2495 ae=-ae;
2496 }
2497 #if DOUBLE
2498 DFWORD(result, 1)=BIN2DPD[ae]; // a single declet
2499 #elif QUAD
2500 DFWORD(result, 1)=0;
2501 DFWORD(result, 2)=0;
2502 DFWORD(result, 3)=(ae/1000)<<10; // is <10, so need no DPD encode
2503 DFWORD(result, 3)|=BIN2DPD[ae%1000];
2504 #endif
2505 return result;
2506 } // decFloatLogB
2507
2508/* ------------------------------------------------------------------ */
2509/* decFloatMax -- return maxnum of two operands */

Callers

nothing calls this directly

Calls 3

decInfinityFunction · 0.85
decFloatDigitsFunction · 0.85
decNaNsFunction · 0.70

Tested by

no test coverage detected