[Courses] [C] Debugging (Re: help me find my C bug? (long))

Jenn Vesperman jenn at anthill.echidna.id.au
Thu Jul 11 03:49:59 EST 2002


On Wed, 2002-07-10 at 14:12, Suzi Anvin wrote:
> heh.  Hey, I'm just happy the bug was related to something I hadn't 
> learned yet.  :)  My chosen fix is to round the sucker in the conversion 
> to int:
> instead of total = amount * 100
>             total = (amount * 100) + 0.5
> 
> Cheesy but it works in this instance.  More elegant solutions welcome 
> just out of curiosity...

My thought was that the fact that you are using 100 (integer literal)
rather than 100.0 (float literal) was causing the code to convert amount
to integer before the multiplication rather that after.

Which can't be the case because it is working for everything except the
last 0.01 value - but is a workable theory!



Jenn V.
-- 
    "Do you ever wonder if there's a whole section of geek culture 
        	you miss out on by being a geek?" - Dancer.

jenn at anthill.echidna.id.au     http://anthill.echidna.id.au/~jenn/





More information about the Courses mailing list