arturo-lang/arturo

[VM/values/operators] [`/`] Verify for Web builds

Opened this issue · 1 comments

[VM/values/operators] [/] Verify for Web builds
we should also check whether big integers work too!
(the same applies to its in-place equivalent)

# TODO(VM/values/operators) [`/`] Verify for Web builds

            objectOperationOrNothing("neg", NegM, oneparam=true, inplace=true)

# TODO(VM/values/operators) [`/`] Verify for Web builds
#  we should also check whether big integers work too!
#  (the same applies to its in-place equivalent)
#  labels: unit-test, web, :integer

proc `/`*(x: Value, y: Value): Value =
    ## divide (integer division) given values and return the result

    let pair = getValuePair()
    case pair:
        of Integer    || Integer        :   return normalIntegerDiv(x.i, y.i)
        of Integer    || BigInteger     :   (when BignumSupport: return newInteger(toBig(x.i) div notZero(y.bi)))
        of BigInteger || Integer        :   (when BignumSupport: return newInteger(x.bi div toBig(notZero(y.i))))
        of BigInteger || BigInteger     :   (when BignumSupport: return newInteger(x.bi div notZero(y.bi)))
        of Integer    || Floating       :   return newFloating(x.i / notZero(y.f))
        of BigInteger || Floating       :   (when defined(GMP): return newFloating(x.bi / notZero(y.f)))
        of Integer    || Rational       :   return newInteger(toRational(x.i) div notZero(y.rat))
        of BigInteger || Rational       :   (when defined(GMP): return newInteger(toRational(x.bi) div notZero(y.rat)))
        of Integer    || Complex        :   return newComplex(float(x.i) / notZero(y.z))

        of Floating   || Integer        :   return newFloating(x.f / float(notZero(y.i)))
        of Floating   || BigInteger     :   (when defined(GMP): return newFloating(x.f / notZero(y.bi)))
        of Floating   || Floating       :   return newFloating(x.f / notZero(y.f))
        of Floating   || Rational       :   return newInteger(toRational(x.f) div notZero(y.rat))
        of Floating   || Complex        :   return newComplex(x.f / notZero(y.z))

        of Rational   || Integer        :   return newRational(x.rat / toRational(notZero(y.i)))
        of Rational   || BigInteger     :   (when defined(GMP): return newRational(x.rat / toRational(notZero(y.bi))))
        of Rational   || Floating       :   return newRational(x.rat / toRational(notZero(y.f)))
        of Rational   || Rational       :   return newRational(x.rat / notZero(y.rat))

021e1bd666fcc7bb6b4d218fd69f2cea608ef718

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.