Compare commits
	
		
			No commits in common. "5910345c08bca370ac67778e37e2ab930d9eacb6" and "3a30d890c629d1f7580225c4961163c4a28c9af1" have entirely different histories.
		
	
	
		
			5910345c08
			...
			3a30d890c6
		
	
		
| @ -34,16 +34,16 @@ func evalMultiply(ctx ExprContext, self *term) (v any, err error) { | ||||
| 		s, _ := leftValue.(string) | ||||
| 		n, _ := rightValue.(int64) | ||||
| 		v = strings.Repeat(s, int(n)) | ||||
| 	} else if isNumOrFract(leftValue) && isNumOrFract(rightValue) { | ||||
| 	} else if isNumber(leftValue) && isNumber(rightValue) { | ||||
| 		if isFloat(leftValue) || isFloat(rightValue) { | ||||
| 			v = numAsFloat(leftValue) * numAsFloat(rightValue) | ||||
| 		} else if isFraction(leftValue) || isFraction(rightValue) { | ||||
| 			v, err = mulAnyFract(leftValue, rightValue) | ||||
| 		} else { | ||||
| 			leftInt, _ := leftValue.(int64) | ||||
| 			rightInt, _ := rightValue.(int64) | ||||
| 			v = leftInt * rightInt | ||||
| 		} | ||||
| 	} else if isFraction(leftValue) || isFraction(rightValue) { | ||||
| 		v, err = mulAnyFract(leftValue, rightValue) | ||||
| 	} else { | ||||
| 		err = self.errIncompatibleTypes(leftValue, rightValue) | ||||
| 	} | ||||
| @ -71,7 +71,7 @@ func evalDivide(ctx ExprContext, self *term) (v any, err error) { | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	if isNumOrFract(leftValue) && isNumOrFract(rightValue) { | ||||
| 	if isNumber(leftValue) && isNumber(rightValue) { | ||||
| 		if isFloat(leftValue) || isFloat(rightValue) { | ||||
| 			d := numAsFloat(rightValue) | ||||
| 			if d == 0.0 { | ||||
| @ -79,8 +79,6 @@ func evalDivide(ctx ExprContext, self *term) (v any, err error) { | ||||
| 			} else { | ||||
| 				v = numAsFloat(leftValue) / d | ||||
| 			} | ||||
| 		} else if isFraction(leftValue) || isFraction(rightValue) { | ||||
| 			v, err = divAnyFract(leftValue, rightValue) | ||||
| 		} else { | ||||
| 			leftInt, _ := leftValue.(int64) | ||||
| 			if rightInt, _ := rightValue.(int64); rightInt == 0 { | ||||
| @ -89,6 +87,8 @@ func evalDivide(ctx ExprContext, self *term) (v any, err error) { | ||||
| 				v = leftInt / rightInt | ||||
| 			} | ||||
| 		} | ||||
| 	} else if isFraction(leftValue) || isFraction(rightValue) { | ||||
| 		v, err = divAnyFract(leftValue, rightValue) | ||||
| 	} else { | ||||
| 		err = self.errIncompatibleTypes(leftValue, rightValue) | ||||
| 	} | ||||
| @ -114,7 +114,7 @@ func evalDivideAsFloat(ctx ExprContext, self *term) (v any, err error) { | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	if isNumOrFract(leftValue) && isNumOrFract(rightValue) { | ||||
| 	if isNumber(leftValue) && isNumber(rightValue) { | ||||
| 		d := numAsFloat(rightValue) | ||||
| 		if d == 0.0 { | ||||
| 			err = errors.New("division by zero") | ||||
|  | ||||
| @ -56,11 +56,7 @@ func evalPlus(ctx ExprContext, self *term) (v any, err error) { | ||||
| 		} | ||||
| 		v = &sumList | ||||
| 	} else if isFraction(leftValue) || isFraction(rightValue) { | ||||
| 		if isFloat(leftValue) || isFloat(rightValue) { | ||||
| 			v = numAsFloat(leftValue) + numAsFloat(rightValue) | ||||
| 		} else { | ||||
| 		v, err = sumAnyFract(leftValue, rightValue) | ||||
| 		} | ||||
| 	} else { | ||||
| 		err = self.errIncompatibleTypes(leftValue, rightValue) | ||||
| 	} | ||||
| @ -86,11 +82,9 @@ func evalMinus(ctx ExprContext, self *term) (v any, err error) { | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	if isNumOrFract(leftValue) && isNumOrFract(rightValue) { | ||||
| 	if isNumber(leftValue) && isNumber(rightValue) { | ||||
| 		if isFloat(leftValue) || isFloat(rightValue) { | ||||
| 			v = numAsFloat(leftValue) - numAsFloat(rightValue) | ||||
| 		} else if isFraction(leftValue) || isFraction(rightValue) { | ||||
| 			v, err = subAnyFract(leftValue, rightValue) | ||||
| 		} else { | ||||
| 			leftInt, _ := leftValue.(int64) | ||||
| 			rightInt, _ := rightValue.(int64) | ||||
| @ -106,6 +100,8 @@ func evalMinus(ctx ExprContext, self *term) (v any, err error) { | ||||
| 			} | ||||
| 		} | ||||
| 		v = &diffList | ||||
| 	} else if isFraction(leftValue) || isFraction(rightValue) { | ||||
| 		v, err = subAnyFract(leftValue, rightValue) | ||||
| 	} else { | ||||
| 		err = self.errIncompatibleTypes(leftValue, rightValue) | ||||
| 	} | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user