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

Function evlFloor

src/jrd/SysFunction.cpp:4455–4529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4453
4454
4455dsc* evlFloor(thread_db* tdbb, const SysFunction*, const NestValueArray& args,
4456 impure_value* impure)
4457{
4458 fb_assert(args.getCount() == 1);
4459
4460 Request* request = tdbb->getRequest();
4461
4462 const dsc* value = EVL_expr(tdbb, request, args[0]);
4463 if (request->req_flags & req_null) // return NULL if value is NULL
4464 return NULL;
4465
4466 EVL_make_value(tdbb, value, impure);
4467
4468 switch (impure->vlu_desc.dsc_dtype)
4469 {
4470 case dtype_short:
4471 case dtype_long:
4472 case dtype_int64:
4473 {
4474 SINT64 scale = getScale<SINT64>(impure);
4475
4476 const SINT64 v1 = MOV_get_int64(tdbb, &impure->vlu_desc, impure->vlu_desc.dsc_scale);
4477 const SINT64 v2 = MOV_get_int64(tdbb, &impure->vlu_desc, 0) * scale;
4478
4479 impure->vlu_misc.vlu_int64 = v1 / scale;
4480
4481 if (v1 < 0 && v1 != v2)
4482 --impure->vlu_misc.vlu_int64;
4483
4484 impure->vlu_desc.makeInt64(0, &impure->vlu_misc.vlu_int64);
4485 }
4486 break;
4487
4488 case dtype_int128:
4489 {
4490 Int128 scale = getScale<CInt128>(impure);
4491
4492 const Int128 v1 = MOV_get_int128(tdbb, &impure->vlu_desc, impure->vlu_desc.dsc_scale);
4493 const Int128 v2 = MOV_get_int128(tdbb, &impure->vlu_desc, 0).mul(scale);
4494
4495 impure->vlu_misc.vlu_int128 = v1.div(scale, 0);
4496
4497 if (v1.sign() < 0 && v1 != v2)
4498 impure->vlu_misc.vlu_int128 -= 1u;
4499
4500 impure->vlu_desc.makeInt128(0, &impure->vlu_misc.vlu_int128);
4501 }
4502 break;
4503
4504 case dtype_real:
4505 impure->vlu_misc.vlu_float = floor(impure->vlu_misc.vlu_float);
4506 break;
4507
4508 default:
4509 impure->vlu_misc.vlu_double = MOV_get_double(tdbb, &impure->vlu_desc);
4510 // fall through
4511
4512 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
MOV_get_doubleFunction · 0.85
makeInt64Method · 0.80
makeInt128Method · 0.80
makeDoubleMethod · 0.80
floorMethod · 0.80
makeDecimal64Method · 0.80
makeDecimal128Method · 0.80
floorFunction · 0.50

Tested by

no test coverage detected