DelphiBasics
Div
Keyword
Performs integer division, discarding the remainder
  Dividend Div Divisor
Description
The Div keyword gives the whole number result of dividing the Dividend by the Divisor.
 
Any remainder is discarded.
Related commands
Mod Performs integer division, returning the remainder
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 Download this web site as a Windows program.




 
Example code : A simple example
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
 
unit Unit1;
 
interface
 
uses
  SysUtils,
  Forms, Dialogs;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;
 
var
  
Form1: TForm1;
 
implementation
{$R *.dfm} // Include form definitions
 
procedure TForm1.FormCreate(Sender: TObject);

var
  int : Integer;

begin
  // Divide a primary integer by 2 - it discards the remainder
  int := 17 Div 2;

  ShowMessage('17 div 2 = '+IntToStr(int));
end;
 
end.
Hide full unit code
   17 div 2 = 8
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Home Page