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

Function evlCeil

src/jrd/SysFunction.cpp:2511–2585  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2509
2510
2511dsc* evlCeil(thread_db* tdbb, const SysFunction*, const NestValueArray& args,
2512 impure_value* impure)
2513{
2514 fb_assert(args.getCount() == 1);
2515
2516 Request* request = tdbb->getRequest();
2517
2518 const dsc* value = EVL_expr(tdbb, request, args[0]);
2519 if (request->req_flags & req_null) // return NULL if value is NULL
2520 return NULL;
2521
2522 EVL_make_value(tdbb, value, impure);
2523
2524 switch (impure->vlu_desc.dsc_dtype)
2525 {
2526 case dtype_short:
2527 case dtype_long:
2528 case dtype_int64:
2529 {
2530 SINT64 scale = getScale<SINT64>(impure);
2531
2532 const SINT64 v1 = MOV_get_int64(tdbb, &impure->vlu_desc, impure->vlu_desc.dsc_scale);
2533 const SINT64 v2 = MOV_get_int64(tdbb, &impure->vlu_desc, 0) * scale;
2534
2535 impure->vlu_misc.vlu_int64 = v1 / scale;
2536
2537 if (v1 > 0 && v1 != v2)
2538 ++impure->vlu_misc.vlu_int64;
2539
2540 impure->vlu_desc.makeInt64(0, &impure->vlu_misc.vlu_int64);
2541 }
2542 break;
2543
2544 case dtype_int128:
2545 {
2546 Int128 scale = getScale<CInt128>(impure);
2547
2548 const Int128 v1 = MOV_get_int128(tdbb, &impure->vlu_desc, impure->vlu_desc.dsc_scale);
2549 const Int128 v2 = MOV_get_int128(tdbb, &impure->vlu_desc, 0).mul(scale);
2550
2551 impure->vlu_misc.vlu_int128 = v1.div(scale, 0);
2552
2553 if (v1.sign() > 0 && v1 != v2)
2554 impure->vlu_misc.vlu_int128 += 1u;
2555
2556 impure->vlu_desc.makeInt128(0, &impure->vlu_misc.vlu_int128);
2557 }
2558 break;
2559
2560 case dtype_real:
2561 impure->vlu_misc.vlu_float = ceil(impure->vlu_misc.vlu_float);
2562 break;
2563
2564 default:
2565 impure->vlu_misc.vlu_double = MOV_get_double(tdbb, &impure->vlu_desc);
2566 // fall through
2567
2568 case dtype_double:

Callers

nothing calls this directly

Calls 15

EVL_exprFunction · 0.85
EVL_make_valueFunction · 0.85
MOV_get_int64Function · 0.85
MOV_get_int128Function · 0.85
ceilFunction · 0.85
MOV_get_doubleFunction · 0.85
makeInt64Method · 0.80
makeInt128Method · 0.80
makeDoubleMethod · 0.80
ceilMethod · 0.80
makeDecimal64Method · 0.80
makeDecimal128Method · 0.80

Tested by

no test coverage detected