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

Function evlLnLog10

src/jrd/SysFunction.cpp:5155–5226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5153
5154
5155dsc* evlLnLog10(thread_db* tdbb, const SysFunction* function, const NestValueArray& args,
5156 impure_value* impure)
5157{
5158 fb_assert(args.getCount() == 1);
5159 fb_assert(function->misc != NULL);
5160
5161 Request* request = tdbb->getRequest();
5162
5163 const dsc* value = EVL_expr(tdbb, request, args[0]);
5164 if (request->req_flags & req_null) // return NULL if value is NULL
5165 return NULL;
5166
5167 if (value->isDecOrInt128())
5168 {
5169 DecimalStatus decSt = tdbb->getAttachment()->att_dec_status;
5170 Decimal128 d = MOV_get_dec128(tdbb, value);
5171
5172 if (d.compare(decSt, CDecimal128(0)) <= 0)
5173 {
5174 status_exception::raise(Arg::Gds(isc_expression_eval_err) <<
5175 Arg::Gds(isc_sysf_argmustbe_positive) <<
5176 Arg::Str(function->name));
5177 }
5178
5179 switch ((Function)(IPTR) function->misc)
5180 {
5181 case funLnat:
5182 d = d.ln(decSt);
5183 break;
5184 case funLog10:
5185 d = d.log10(decSt);
5186 break;
5187 default:
5188 fb_assert(0);
5189 return NULL;
5190 }
5191
5192 impure->vlu_misc.vlu_dec128 = d;
5193 impure->vlu_desc.makeDecimal128(&impure->vlu_misc.vlu_dec128);
5194 }
5195 else
5196 {
5197 const double v = MOV_get_double(tdbb, value);
5198
5199 if (v <= 0)
5200 {
5201 status_exception::raise(Arg::Gds(isc_expression_eval_err) <<
5202 Arg::Gds(isc_sysf_argmustbe_positive) <<
5203 Arg::Str(function->name));
5204 }
5205
5206 double rc;
5207
5208 switch ((Function)(IPTR) function->misc)
5209 {
5210 case funLnat:
5211 rc = log(v);
5212 break;

Callers

nothing calls this directly

Calls 15

EVL_exprFunction · 0.85
MOV_get_dec128Function · 0.85
CDecimal128Class · 0.85
raiseFunction · 0.85
GdsClass · 0.85
StrClass · 0.85
MOV_get_doubleFunction · 0.85
isDecOrInt128Method · 0.80
lnMethod · 0.80
log10Method · 0.80
makeDecimal128Method · 0.80
makeDoubleMethod · 0.80

Tested by

no test coverage detected