Discussion: Question on the FAQ
Afficher un message
Vieux 13/04/2008, 22h33   #5
Flash Gordon
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Question on the FAQ

Topi Linkala wrote, On 13/04/08 20:48:
> Robert Gamble wrote:
>
>> On Apr 13, 3:33 pm, Topi Linkala <n...@iki.fi> wrote:
>>
>>> Question 3.15:
>>>
>>> Why does the code
>>>
>>> double degC, degF;
>>> degC = 5 / 9 * (degF - 32);
>>>
>>> keep giving me 0?
>>>
>>> Would the following rearrangement solve the problem?
>>>
>>> degC = 5 * (degF - 32) / 9;

>>
>> Did you read the answer to the question (<http://c-faq.com/expr/
>> truncation1.html>)?

>
> Yes I read and it says:
>
> "If both operands of a binary operator are integers, C performs an
> integer operation,..."


Which is why it does not work.

> But in my rewriting there are no binary operation with integer values.


Which is why it would work.

> That's why I'm asking if it would work.


You obviously did not make it clear enough to Robert that you had read
it. Don't worry about it.
--
Flash Gordon
  Réponse avec citation
 
Page generated in 0,05536 seconds with 9 queries