Solved

# Problem with int() and trunc() !

Posted on 1998-05-20

Math problem !!!!!!!!

normally int(226.0) returns 226 and

trunc(226.0) returns 226

But I am getting both returning 225

in the code below !

function EvenCmClasses(OriginalHt:Double) : Double;

{Converts X to an even cm class, and rounds to two decimals}

var

Ht100, Ht1000, InitialClass : Double;

CorrectIt : LongInt;

begin

Ht100:= OriginalHt*100.0;

Ht1000:= OriginalHt*1000.0;

CorrectIt:= Trunc(Ht100);

InitialClass:= CorrectIt/100.0;

{InitialClass:= Int(Ht100)/100.0;}

The OriginalHt comes from a sum of a

TOvcPictureArrayEditor set to datatype = ptfDouble

Watches shows OriginalHt = 226

Can anyone give me some help with this ?

John.