Sie sind auf Seite 1von 2

2/10/2015 DelphiBasics:Trunccommand

DelphiBasics ContactNeiltoadvertisehere

Trunc Theintegerpartofafloatingpointnumber Systemunit


Function

functionTrunc(constNumber:Extended):Integer


Description Examplecode:Asimpleexample

TheTruncfunctionreturnstheintegerpartofafloatingpoint begin
number. ShowMessage('Round(12.75)='+IntToStr(Round(12.75)))
ShowMessage('Trunc(12.75)='+IntToStr(Trunc(12.75)))
ItreturnsthispartasanIntegervalue.
ShowMessage('Int(12.75)='+FloatToStr(Int(12.75)))
ShowMessage('Frac(12.75)='+FloatToStr(Frac(12.75)))
Notes end
Showfullunitcode
TheIntfunctiondoesthesame,butreturnstheintegerina
floatingpointvalue.
Round(12.75)=13
Trunc(12.75)=12
Relatedcommands Int(12.75)=12
Frac(12.75)=0.75
Frac Thefractionalpartofafloatingpointnumber
Int Theintegerpartofafloatingpointnumberasafloat
Round Roundsafloatingpointnumbertoaninteger

DownloadthiswebsiteasaWindowsprogram.

http://www.delphibasics.co.uk/RTL.asp?Name=Trunc 1/2
2/10/2015 DelphiBasics:Trunccommand

DelphiProgrammingNeilMoffatt20022015.Allrightsreserved.|Contacttheauthor|HomePage

http://www.delphibasics.co.uk/RTL.asp?Name=Trunc 2/2

Das könnte Ihnen auch gefallen