RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
System.Odd Function

Returns true if argument is an odd number.

Pascal
function Odd(X: Integer): Boolean;
C++
Boolean Odd(int X);

In Delphi code, Odd tests if the argument is an odd number. It returns true if X is an odd number, false if X is even.  

Delphi Examples: 

 

{
This example requires a text edit and a button with some clear
canvas in the top left ocrner of the form.  Enter the number to be
tested in the text edit and click to button to test if the entry
is odd.
}
procedure TForm1.Button1Click(Sender: TObject);
begin
   Canvas.TextOut(10, 10, '                                          ');
   if Odd(StrToInt(Edit1.Text)) then
     Canvas.TextOut(10, 10, Edit1.Text + ' is odd.')
   else
     Canvas.TextOut(10, 10, Edit1.Text + ' is even.');
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!