OWBasic for Pocketviewer

Home INTRO Group IFUNC Alphabetical Index

Combined Multiplication and Division

MULDIV(a%,b%,c%)

Calculates the value a*b/c, whereby the value of a*b may exceed the integer range. This is a frequently used method, in order to multiply the integer a with a fractional number (b/c).

Example:

Perimeter of a circle with the radius r:
U= r * 355 / 113

This good approximation leads to an overflow even for small r. With MULDIV this is avoided, as long as only u does not exceed the integer range:
U=MULDIV(r,355,113)


Home INTRO Group IFUNC Alphabetical Index