From 63916cc32a6918a3f8c13620aa6ca330ee43c6f9 Mon Sep 17 00:00:00 2001 From: Brad Arant Date: Mon, 24 Nov 2025 13:19:31 -0800 Subject: [PATCH] Added FLOOR and CEIL function in operand. --- Operand.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Operand.cpp b/Operand.cpp index af8bee7..671a345 100644 --- a/Operand.cpp +++ b/Operand.cpp @@ -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.");