Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!kddlab!titcca!sragwa!wsgw!socslgw!diamond!diamond From: diamond@diamond.csl.sony.junet (Norman Diamond) Newsgroups: comp.lang.pascal Subject: Re: Realint qestion Message-ID: <10247@socslgw.csl.sony.JUNET> Date: 14 May 89 10:02:05 GMT References: <19573@adm.BRL.MIL> <21930@santra.UUCP> Sender: news@csl.sony.JUNET Reply-To: diamond@csl.sony.junet (Norman Diamond) Organization: Sony Computer Science Laboratory Inc., Tokyo, Japan Lines: 33 In article <21930@santra.UUCP> s32935k@taltta.hut.fi (Carl Torsten Stenholm) writes: >I was looking at a bit of software posted on the net and there was a function >looking like this (I hope I don't break any copyrights now...) >function realint (x: real): real; >begin > realint := x - (x - trunc (x)); >end; >As far as I can see this must be the same as >function realint (x: real): real; (* inserting on your behalf *) var nt : integer; >begin > realint := nt := trunc (x); >end; >Well now the only difference between this function and putting "trunc (x)" >directly in the code is that trunc returns an integer (I think). In that >case -- is there any situation where you must have an real returned instead >of an integer and thus forced to use this function ? Suppose MAXINT is 2147whatever (about 2 billion), and x is -2.35e+3000 ? -- Norman Diamond, Sony Computer Science Lab (diamond%csl.sony.co.jp@relay.cs.net) The above opinions are my own. | Why are programmers criticized for If they're also your opinions, | re-implementing the wheel, when car you're infringing my copyright. | manufacturers are praised for it?