PDA

View Full Version : GCD doesn't handle division well?!



skulakowski
03-27-2006, 10:00 AM
Can anybody explain this odd behavior of the greatest common divisor (GCD) function?

Correctly, GCD(440, 460) = 20.

Also correctly, GCD( (440*100) / 100, (460*100) / 100) = 20

BUT... GCD( (440/100) *100, (460/100) * 100) = 1.

Seems to me that 440/100 * 100 equals 440*100 / 100 equals 440.

I'll round any divisions I use but I'd like to understand why I have to round.

Thanks.

mdmackillop
03-27-2006, 10:20 AM
It certainly seems a little bizarre. I put your values in the attached spreadsheet. Playing around with the values in the yellow cells gave me a GCD of 459 when both values are 460!