Some data-type check functions (e.g. IsInteger()) exported

This commit is contained in:
2024-05-08 07:53:01 +02:00
parent b2b0bb04c5
commit 8ee0bb5701
13 changed files with 44 additions and 44 deletions
+4 -4
View File
@@ -30,12 +30,12 @@ func evalMultiply(ctx ExprContext, self *term) (v any, err error) {
return
}
if isString(leftValue) && isInteger(rightValue) {
if IsString(leftValue) && IsInteger(rightValue) {
s, _ := leftValue.(string)
n, _ := rightValue.(int64)
v = strings.Repeat(s, int(n))
} else if isNumOrFract(leftValue) && isNumOrFract(rightValue) {
if isFloat(leftValue) || isFloat(rightValue) {
if IsFloat(leftValue) || IsFloat(rightValue) {
v = numAsFloat(leftValue) * numAsFloat(rightValue)
} else if isFraction(leftValue) || isFraction(rightValue) {
v, err = mulAnyFract(leftValue, rightValue)
@@ -72,7 +72,7 @@ func evalDivide(ctx ExprContext, self *term) (v any, err error) {
}
if isNumOrFract(leftValue) && isNumOrFract(rightValue) {
if isFloat(leftValue) || isFloat(rightValue) {
if IsFloat(leftValue) || IsFloat(rightValue) {
d := numAsFloat(rightValue)
if d == 0.0 {
err = errors.New("division by zero")
@@ -148,7 +148,7 @@ func evalReminder(ctx ExprContext, self *term) (v any, err error) {
return
}
if isInteger(leftValue) && isInteger(rightValue) {
if IsInteger(leftValue) && IsInteger(rightValue) {
rightInt, _ := rightValue.(int64)
if rightInt == 0 {
err = errors.New("division by zero")