rename package

This commit is contained in:
2025-07-13 07:02:26 +02:00
parent 63284ab51c
commit f063aadcd8
24 changed files with 24 additions and 24 deletions

View File

@@ -0,0 +1,32 @@
package statevariables
import "fmt"
// valuesToNumericOperands takes two interface{} values, casts them to a numeric type based on a given StateVarType, and returns their float64 equivalents.
// If any error occurs during casting or conversion to float64, it is returned along with zero values for the operands.
func valuesToNumericOperands(t StateVarType, a interface{}, b interface{}) (float64, float64, error) {
var err error
if !t.IsNumeric() {
return 0, 0, fmt.Errorf("type %v is not numeric", t)
}
a, err = t.Cast(a)
if err != nil {
return 0, 0, err
}
b, err = t.Cast(b)
if err != nil {
return 0, 0, err
}
af, err := toFloat(a, 64)
if err != nil {
return 0, 0, err
}
bf, err := toFloat(b, 64)
if err != nil {
return 0, 0, err
}
return af, bf, nil
}