Log in

View Full Version : Problem with Rounding...



snuwoods
04-07-2007, 01:05 AM
Hey-
First of all, does anyone know a function that will determine if a number is odd or not?
I think I've got a half-working script anyway.
The problem:var
z: Extended;
k: Integer;

const
x = 21;

begin
cleardebug;
z := x;
z := (z)*(0.5);
WriteLn(FloatToStr(z));
k := (Round(z));
WriteLn(FloatToStr(k));
k := (k-1);
WriteLn(IntToStr(k));
if(z>(k))and(z<(k+1))then
WriteLn('The Number is Odd')
else
WriteLn('The Number is Even');
end.

I think it just rounds z/2....not 10.5 or whatever else it is. Could someone just help me out here...ty :rolleyes:
Also, how does one go about naming the version of a script?

ty
--
snuwoods

Boreas
04-07-2007, 01:09 AM
if (num mod 2) = 0 then


Edit: in function form

function IsEven (TheNumber : integer): boolean;
begin
result:= (TheNumber mod 2) = 0;
end;

Santa_Clause
04-07-2007, 06:12 AM
Boreas, Don't You Ever Get Tired Of Posting...?

Boreas
04-07-2007, 06:24 AM
There are a lot of posts I see that I could answer, but I just don't feel like it. But this one took like 30 seconds :)

Infantry001
04-09-2007, 04:09 AM
it must feel good to be able to answer so many questions, and not really have to... :P