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

Function grab

src/common/DecFloat.cpp:238–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236}
237
238void grab(ULONG* key,
239 const unsigned pMax, const int bias, const unsigned decSize,
240 unsigned char* bcd, int& sign, int& exp, decClass& cl)
241{
242 exp = *key++;
243 sign = 0;
244
245 if (exp == MAX_SLONG || exp == ~MAX_SLONG) // special value
246 {
247 unsigned dig = decSize / sizeof(ULONG);
248 fb_assert(!(decSize % sizeof(ULONG)));
249 ULONG offset = key[dig - 1];
250
251 if (exp == ~MAX_SLONG)
252 {
253 sign = DECFLOAT_Sign;
254 offset = ~offset;
255 }
256
257 offset = MAX_SLONG - offset;
258 switch(offset)
259 {
260 case OFF_inf:
261 cl = sign ? DEC_CLASS_NEG_INF : DEC_CLASS_POS_INF;
262 break;
263 case OFF_snan:
264 cl = DEC_CLASS_SNAN;
265 break;
266 case OFF_nan:
267 cl = DEC_CLASS_QNAN;
268 break;
269 default:
270 (Arg::Gds(isc_random) << "Invalid class of special decfloat value in sort key").raise();
271 }
272
273 return;
274 }
275
276 // normal value
277 // here we ignore differences in class for SUBNORMAL, ZERO and NEG
278 cl = DEC_CLASS_POS_NORMAL;
279
280 // parse exp
281 if (exp < 0)
282 {
283 sign = DECFLOAT_Sign;
284 exp = -exp;
285 }
286
287 if (exp != 0)
288 exp -= (bias + 2);
289
290 // convert from SLONG
291 for (int i = pMax; i--;)
292 {
293 int c = i / 9;
294 bcd[i] = key[c] % 10;
295 key[c] /= 10;

Callers 1

grabKeyMethod · 0.85

Calls 2

GdsClass · 0.85
raiseMethod · 0.45

Tested by

no test coverage detected