It's a bug? Re: Strange problem
- Posted by Joel Crook <joel at MAIL.K-A.COM> Mar 18, 2000
- 456 views
--=====================_481794395==_.ALT At 11:50 PM 03/18/2000 -0500, you wrote: >Everett Williams wrote: > >Sometimes I am a little slow, but I do finally get there. In a case where the >system truncates rather than rounds, the normal solution is to add .5 >except in this case where we are not sure that the conversion is always >less than the original decimal number. Given the answer to that question is >yes, then adding .5 solves the problem. Only a lot of very exacting testing or >an answer from RDS will solve the question for sure. > >Everett L.(Rett) Williams >rett at gvtc.com I modified his code a little bit and found something interesting: include misc.e global constant POSITION = 4, LEFT = 4.1, TOP = 4.2, DEMINSIONS = 5, WIDTH = 5.1, HEIGHT = 5.2, objects = { {1,0,{},{ 0, 0},{639,479}, 1,1,1}, {1,0,{},{10,10},{459,459},-1,1,1} } global function Get (integer obj, atom att) atom b integer a b=att - floor (att) b=b*10 a=floor(b) ? att ? b ? a return objects [obj] [att] end function object view view = 2 constant vp = {Get (view,WIDTH),Get (view, HEIGHT)} ? ({Get(view,LEFT), Get(view,TOP)}) -- -- the following numbers are returned: 5.1 -- this is att 1 -- this is b 0 <----- This is the result of a= floor(b) Notice ----This "should be" 1 --- I think this is a bug 5.2 2 2 <----- the second number is ok 4.1 1 0 <----- Notice ----again floor (b) fails 4.2 2 2<----- the fourth number is ok I'd say Lewis found a bug in the Euphoria code. Joel H. Crook Manager, Information Services Certified Novell Administrator Microsoft Certified Professional, OS Specialist Kellogg & Andelson Accountancy Corp. 14724 Ventura Blvd. 2nd Floor Sherman Oaks, CA 91403 (818) 971-5100 --=====================_481794395==_.ALT <html> At 11:50 PM 03/18/2000 -0500, you wrote:<br> >Everett Williams wrote:<br> ><br> >Sometimes I am a little slow, but I do finally get there. In a case where the<br> >system truncates rather than rounds, the normal solution is to add .5<br> >except in this case where we are not sure that the conversion is always<br> >less than the original decimal number. Given the answer to that question is<br> >yes, then adding .5 solves the problem. Only a lot of very exacting testing or<br> >an answer from RDS will solve the question for sure.<br> ><br> >Everett L.(Rett) Williams<br> >rett at gvtc.com<br> <br> <br> I modified his code a little bit and found something interesting:<br> <br> <br> include misc.e<br> <br> global constant<br> POSITION = 4,<br> LEFT = 4.1,<br> TOP = 4.2,<br> DEMINSIONS = 5,<br> WIDTH = 5.1,<br> HEIGHT = 5.2,<br> objects = {<br> {1,0,{},{ 0, 0},{639,479}, 1,1,1},<br> {1,0,{},{10,10},{459,459},-1,1,1}<br> <br> }<br> <br> global function Get (integer obj, atom att) <dl> <dd>atom b <dd>integer a <dd>b=att - floor (att) <dd>b=b*10 <dd>a=floor(b) <dd>? att <dd>? b <dd>? a <dd>return objects [obj] [att]<br> <br> </dl>end function<br> <br> object view<br> view = 2<br> <br> <br> constant vp = {Get (view,WIDTH),Get (view, HEIGHT)}<br> ? ({Get(view,LEFT), Get(view,TOP)})<br> --<br> <br> -- the following numbers are returned:<br> <br> 5.1 <x-tab> </x-tab>-- this is att<br> 1<x-tab> </x-tab>-- this is b <br> 0 <----- This is the result of a= floor(b) Notice ----This "should be" 1 --- I think this is a bug<br> 5.2<br> 2<br> 2 <----- the second number is ok<br> 4.1<br> 1<br> 0 <----- Notice ----again floor (b) fails<br> 4.2<br> 2<br> 2<----- the fourth number is ok<br> <br> I'd say Lewis found a bug in the Euphoria code.<br> <br> <br> Joel H. Crook<br> <br> Manager, Information Services<br> <font size=1>Certified Novell Administrator<br> Microsoft Certified Professional, OS Specialist<br> <br> </font><b>Kellogg & Andelson Accountancy Corp.<br> </b><font size=1>14724 Ventura Blvd. 2nd Floor<br> Sherman Oaks, CA 91403<br> (818) 971-5100<br> </font></html> --=====================_481794395==_.ALT--