This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.

Hi. Awhile back, I found a class that takes a decimal value and converts it to a fraction. It seemed to have been working OK, but a couple of users noticed some decimal values not converting properly. The two they've noticed so far are : .781 should convert to 25/32, but it's converting to 7/9. .625 should convert to 3/8, but it's converting to 3/5. I tried to look at the code and figure out what was going on, but I guess I really don't understand everything that is going on to get fraction values. Could someone take a look at the method that is supposed to be converting the value to a fraction, and help me understand why it is doing it? Here's the method: (Sorry it's so long)

I appreciate ANY help anyone can give me on this. Thanks again!!