Divide()

Namespace ›› System ›› MfInteger ›› Methods ››
Parent Previous Next

Divide()

OutputVar := instance.Divide(value)

Divide(value)

Divides the current instance of MfInteger by the divisor value.

Parameters

value

The Divisor value to divide the current instance Value by.
Can be any type that matches IsNumber. or var number.

Returns

If ReturnAsObject is true then returns current instance of MfInteger with an updated Value; Otherwise returns Value as var.

Throws

Throws MfNotSupportedException if Readonly is true.
Throws MfNullReferenceException if called as a static method
Throws MfArgumentNullException if value is null.
Throws MfDivideByZeroException if value is zero.
Throws MfArithmeticException if the operation fails or value is not an instance of MfInteger and can not be converted into integer value.
Throws MfArgumentOutOfRangeException if dividing result is less then MinValue and greater than MaxValue

Remarks

If the result of the operation is not a whole number such as 4/2 but rather a float number such as 8/3 (8/3 = 2.6666...) then the result will always be the whole number portion of the operation. For example:

mfInt := new MfInteger(8)
MsgBox % mfInt.Divide(3) ; displays 2

mfInt.Value := 8
MsgBox % mfInt.Divide(-3) ; displays -2

If you need to work with decimal/float numbers see MfFloat

Example

i := new MfInteger(80, true) ; create new MfInteger and set it RetrunAsObject to value to true

iNew := new MfInteger(8)
MsgBox % i.Divide(iNew).Value ; displays 10
Msgbox % i.Add(-5).Value ; displays 5
MsgBox % i.Add(10).Divide(2).Value ; displays 14