Floor and Ceiling Functions - Math is Fun

文章推薦指數: 80 %
投票人數:10人

The floor and ceiling functions give us the nearest integer up or down. Example: What is the floor and ceiling of 2.31? Floor and Ceiling function. The Floor of ... Advanced ShowAds HideAds AboutAds FloorandCeilingFunctions Thefloorandceilingfunctionsgiveusthenearestintegerupordown. Example:Whatisthefloorandceilingof2.31? TheFloorof2.31is2 TheCeilingof2.31is3 FloorandCeilingofIntegers Whatifwewantthefloororceilingofanumberthatisalreadyaninteger? That'seasy:nochange! Example:Whatisthefloorandceilingof5? TheFloorof5is5 TheCeilingof5is5 Herearesomeexamplevaluesforyou: x Floor Ceiling −1.1 −2 −1 0 0 0 1.01 1 2 2.9 2 3 3 3 3 Symbols Thesymbolsforfloorandceilingarelikethesquarebrackets[]withthetoporbottompartmissing: ButIprefertousethewordform:floor(x)andceil(x) Definitions Howdowegivethisaformaldefinition? Example:Howdowedefinethefloorof2.31? Well,ithastobeaninteger... ...andithastobelessthan(ormaybeequalto)2.31,right? 2islessthan2.31... but1isalsolessthan2.31, andsois0,and-1,-2,-3,etc. Ohno!Therearelotsofintegerslessthan2.31.   Sowhichonedowechoose? Choosethegreatestone(whichis2inthiscase) Soweget: Thegreatestintegerthatislessthan(orequalto)2.31is2 Whichleadstoourdefinition: FloorFunction:thegreatestintegerthatislessthanorequaltox LikewiseforCeiling: CeilingFunction:theleastintegerthatisgreaterthanorequaltox AsAGraph TheFloorFunctionisthiscurious"step"function(likeaninfinitestaircase): TheFloorFunction Asoliddotmeans"including"andanopendotmeans"notincluding". Example:atx=2wemeet: anopendotaty=1(soitdoesnotincludex=2), andasoliddotaty=2(whichdoesincludex=2) sotheanswerisy=2 AndthisistheCeilingFunction: TheCeilingFunction The"Int"Function The"Int"function(shortfor"integer")islikethe"Floor"function,BUTsomecalculatorsandcomputerprogramsshowdifferentresultswhengivennegativenumbers: Somesayint(−3.65)=−4(thesameastheFloorfunction) Otherssayint(−3.65)=−3(theneighbouringintegerclosesttozero,or"justthrowawaythe.65") Sobecarefulwiththisfunction! The"Frac"Function WiththeFloorFunction,we"throwaway"thefractionalpart.Thatpartiscalledthe"frac"or"fractionalpart"function: frac(x)=x−floor(x) Itlookslikeasawtooth: TheFracFunction Example:whatisfrac(3.65)? frac(x)=x−floor(x) So:frac(3.65)=3.65−floor(3.65)=3.65−3=0.65 Example:whatisfrac(−3.65)? frac(x)=x−floor(x) So:frac(−3.65)=(−3.65)−floor(−3.65)=(−3.65)−(−4)=−3.65+4=0.35   BUTmanycalculatorsandcomputerprogramsusefrac(x)=x−int(x),andsotheirresultdependsonhowtheycalculateint(x): Somesayfrac(−3.65)=0.35i.e−3.65−(−4) Otherssayfrac(−3.65)=−0.65i.e.−3.65−(−3) Sobecarefulusingthisfunctionwithnegativevalues.     CommonFunctionsReferenceSetsIndex Copyright©2017MathsIsFun.com



請為這篇文章評分?