Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!spool.mu.edu!uunet!bu.edu!m2c!wpi.WPI.EDU!kamal From: kamal@wpi.WPI.EDU (Kamal Z Zamli) Newsgroups: comp.lang.pascal Subject: Re: Is this not a bug? Message-ID: <1991Feb20.180329.21182@wpi.WPI.EDU> Date: 20 Feb 91 18:03:29 GMT References: <1991Feb20.170152.5401@ux1.cso.uiuc.edu> Organization: Worcester Polytechnic Institute Lines: 38 In article <1991Feb20.170152.5401@ux1.cso.uiuc.edu> mead@uxh.cso.uiuc.edu (Alan David Mead) writes: >I finally tracked down a problem with an application writen in >TP5.5: Since my values are all positive, I used words instead of >integers. The ABS() function, however, does not operate as (I) >expected with word parameters. This code demonstrates. While I >can imagine how the value is produced by ABS(), I think the manual's >description is deceptive. What does the net think? >============================================================ >program damnit; > >const > Start : integer = 900; > >var > w1,w2 : word; > i1, i2 : integer; > > function Value:word; > begin > Start := Start - 200; > Value := Start; > end; > >begin > w1 := Value; > w2 := Value; > writeln( 'ABS( ',w2,' - ',w1,' ) =? ',abs( w2 - w1 )); > > i1 := Value; > i2 := Value; > writeln( 'ABS( ',i2,' - ',i1,' ) =? ',abs( i2 - i1 )); >end. I might be wrong but I dont think you can change a constant.....and expect it to be the same again.. In order to avoid such problem just declare a dummy var and assign it to var start each time the fucntion is called. hope that help