Re: It's a bug? Re: Strange problem
- Posted by Joel Crook <joel at MAIL.K-A.COM> Mar 19, 2000
- 433 views
--=====================_1550049==_.ALT At 09:38 AM 03/19/2000 -0500, you wrote: >On Sun, 19 Mar 2000, Joel Crook wrote: >> >> I'd say Lewis found a bug in the Euphoria code. >> >Yes, it is a bug, but not in the floor() function. >When you create a constant, or pass a value: >for example, Get(4.1), it actually passes a number >"close" to 4.1. See the test code below, which >produces these results: > >att: 4.09999999999999964473 >b: (att-floor(att) * 10) 0.99999999999999644729 >a: (floor(b)) 0.00000000000000000000 >att: 5.09999999999999964473 >b: (att-floor(att) * 10) 0.99999999999999644729 >a: (floor(b)) 0.00000000000000000000 That explains why, as I was puttering with the code last night, if I made "att" slightly larger-- say 4.11 that the conversion worked... >Therefore, floor() is doing what it is supposed to do, >round off to a whole number less than or equal to the >value passed. The problem is in how to pass exactly the >value you want to pass. <SNIP!> >Regards, >Irv Thanks Irv for the lesson on floats in Euphoria. I'll have to try this in TP7 and see what it does.. Thanks again, Joel Joel H. Crook "When the code works perfectly, the program is obsolete." -- "The Gosple According to St. Murphy" --=====================_1550049==_.ALT <html><div>At 09:38 AM 03/19/2000 -0500, you wrote:</div> <div>>On Sun, 19 Mar 2000, Joel Crook wrote:</div> <div>>></div> <div>>> I'd say Lewis found a bug in the Euphoria code.</div> <div>>></div> <div>>Yes, it is a bug, but not in the floor() function.</div> <div>>When you create a constant, or pass a value:</div> <div>>for example, Get(4.1), it actually passes a number</div> <div>>"close" to 4.1. See the test code below, which</div> <div>>produces these results:</div> <div>></div> <div>>att: 4.09999999999999964473</div> <div>>b: (att-floor(att) * 10) 0.99999999999999644729</div> <div>>a: (floor(b)) 0.00000000000000000000</div> <div>>att: 5.09999999999999964473</div> <div>>b: (att-floor(att) * 10) 0.99999999999999644729</div> <div>>a: (floor(b)) 0.00000000000000000000</div> <br> <div>That explains why, as I was puttering with the code last night, </div> <div>if I made "att" slightly larger-- say 4.11 that the conversion worked...</div> <br> <br> <div>>Therefore, floor() is doing what it is supposed to do,</div> <div>>round off to a whole number less than or equal to the</div> <div>>value passed. The problem is in how to pass exactly the</div> <div>>value you want to pass.</div> <div><SNIP!></div> <div>>Regards,</div> <div>>Irv</div> <br> <div>Thanks Irv for the lesson on floats in Euphoria.</div> <br> <div> I'll have to try this in TP7 and see what it does..</div> <br> <div>Thanks again,</div> <br> <div>Joel</div> <br> Joel H. Crook<br> <br> "<b><i>When the code works perfectly, the program is obsolete</b></i>."<br> <div align="right"> -- "The Gosple According to St. Murphy"</html> --=====================_1550049==_.ALT--