``

prev Menu next

Introduction to BASIC Quotients and Remainders
Quotients of a division
The quotient of a divided by b is obtained by INT(a / b).
INT(x) stands for the largest integer not greater than x.
If x is a positive number, INT(x) coincides with the truncated number.
Remainder of division
The remainder of a divided by a positive number b is obtained by a-b*INT(a / b) or MOD(a,b).
[Note]
The remainder for real numbers
For a real number a and a positive real number b, there exists a unique integer q and a real number r such that 0≤r<b.
On this case, q is called the quotient, and r the remainder.

Example. A program which finds a number of bottles and the volume of the rest when x litre of liquid is divided into the bottles of capacity 1.8 litre.

    10 INPUT x
    20 PRINT INT(x/1.8),MOD(x,1.8)
    30 END