Skip to content

Implement math/big evaluate operations #433

Open
@vivlis

Description

@vivlis

Hello,

I like this package, but I have problem with floating numbers as for data type float64 limitation, which for my case is rounding and unmarshaling from JSON.

Describe the solution you'd like
Would like to propose implementation math/big to standard evaluation (https://github.com/hyperjumptech/grule-rule-engine/blob/master/pkg/reflectmath.go).
it can be done with something similar like:
if left.Type().String() == "big.Float" && right.Type().String() == "big.Float" {
leftValue := left.Interface().(big.Float)
rightValue := right.Interface().(big.Float)
return reflect.ValueOf(leftValue.Cmp(&rightValue) == 1), nil
}

Describe alternatives you've considered
I've considered to create custom function with strings inputs, which will/is #working nicely, but I think above could be nice addition to package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions