import (
"math"
+ "math/big"
"github.com/bytom/vapor/math/checked"
)
}
return vm.pushBool(x >= min && x < max, true)
}
+
+func opMulFraction(vm *virtualMachine) error {
+ if err := vm.applyCost(8); err != nil {
+ return err
+ }
+
+ z, err := vm.popInt64(true)
+ if err != nil {
+ return err
+ }
+
+ if z == 0 {
+ return ErrDivZero
+ }
+
+ y, err := vm.popInt64(true)
+ if err != nil {
+ return err
+ }
+
+ x, err := vm.popInt64(true)
+ if err != nil {
+ return err
+ }
+
+ res := big.NewInt(x)
+ res.Mul(res, big.NewInt(y)).Quo(res, big.NewInt(z))
+ if !res.IsInt64() {
+ return ErrRange
+ }
+
+ return vm.pushInt64(res.Int64(), true)
+}