Some data-type check functions (e.g. IsInteger()) exported
This commit is contained in:
+4
-4
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user