JOIN
Get Time
forums   
Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings
View: Flat  | Threaded  | Tree
Previous Thread  |  Next Thread
fractional values | Reply
I'm wondering how we should deal with comparing and returning fractional values in our programs to get the correct output. For example, either in the first round of this tournament or in an early beta, the problem was given to write a method that calculates when two trains or trucks heading toward each other would meet. In the challenge round I challenged someone's code, and my challenge succeeded because "the method returned 50.666667 when it should have returned 50.666666" or something like that. I'm guessing that this difference is just rounding error. The problem came up again for me in the Triangle problem in a beta last week. I stored the sides of triangle as doubles, and when I tested my code, sides that I know should have been equal tested not equal, I'm guessing because of rounding in the calculations. In this case, it may be that I don't know the proper way to compare doubles. At any rate, I'm wondering if anyone else has had similar problems or has any suggestions.
-montague
Subject Author Date
fractional values montague Apr 22, 2001 at 4:11 PM EDT
Re: fractional values unlord Apr 22, 2001 at 4:40 PM EDT
Re: fractional values Soli Apr 22, 2001 at 7:24 PM EDT
Re: fractional values ads09 Apr 23, 2001 at 9:43 AM EDT
RSS