Added FLOOR and CEIL function in operand.

This commit is contained in:
Brad Arant 2025-11-24 13:19:31 -08:00
parent 5e0523619d
commit 63916cc32a

View File

@ -328,9 +328,27 @@ namespace jet {
} else
throw coreutils::Exception("Expecting ) at end of TRUNC expression.");
} else if(in.ifNextIgnoreCase("CEIL")) {
if(!in.ifNext("("))
throw coreutils::Exception("Expecting ( for CEIL parameters.");
Operand parm1(in, tag);
if(in.ifNext(")")) {
doubleValue = ceil(parm1.doubleValue);
isNumber = true;
string = std::format("{:.12f}", doubleValue);
string.removeTrailingZeros();
} else
throw coreutils::Exception("Expecting ) at end of CEIL expression.");
} else if(in.ifNextIgnoreCase("FLOOR")) {
if(!in.ifNext("("))
throw coreutils::Exception("Expecting ( for FLOOR parameters.");
Operand parm1(in, tag);
if(in.ifNext(")")) {
doubleValue = floor(parm1.doubleValue);
isNumber = true;
string = std::format("{:.12f}", doubleValue);
string.removeTrailingZeros();
} else
throw coreutils::Exception("Expecting ) at end of FLOOR expression.");
} else if(in.ifNextIgnoreCase("UNIXTIME")) {
if(!in.ifNext("("))
throw coreutils::Exception("Expecting ( for UNIXTIME.");