xHarbour Reference Documentation > Operator Reference xHarbour Developers Network  

%

Modulus operator (binary): calculates the remainder of a division.

Syntax

<nNumber1> % <nNumber2>

Arguments

<nNumber1>
<nNumber1> is the dividend of the division.
<nNumber2>
<nNumber2> is the divisor of the division.

Description

The modulus operator returns the remainder of dividing <nNumber1> by <nNumber2>.

Info

See also:*, **, +, -, /, = (compound assignment), SET FIXED
Category: Mathematical operators , Operators
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example calculates the remainder of a division
// between two numbers.

   PROCEDURE Main
      ? 5 % 0                          // result:  0
      ? 3 % 2                          // result:  1
      ? -2 % 3                         // result: -2
      ? 4 % 2                          // result:  0

      ? 5.4 % 2.3                      // result: 0.8
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe