C - zaokrouhlovani
Miroslav Šinko
sinkomiro na gmail.com
Neděle Únor 20 14:41:24 CET 2011
Delenie celych cisel v C sa nezaokruhluje. Norma to definuje takto:
The result of the / operator is the quotient from the division of the
first operand by the
second; the result of the % operator is the remainder. In both
operations, if the value of
the second operand is zero, the behavior is undefined.
miro
2011/2/20 Michal Gregor <a2x1nptda8 na email.cz>:
> Zdravim pocitam v C s celymi cisly. Promenne 32bitu signed.
>
> -17840128 / 7611 = -2343,9926422283536985941400604388
>
> V prikladu z netu jim to vychazi 2344, tedy zaokrouhleno nahoru.
> Ale Hitech C18 zaokrouhluje dolu tedy na 2343.
> Je v norme pro C dano jak se maji cisla zaokrouhlovat v pripade vypoctu pro
> cele cisla?
>
> Michal Gregor
Další informace o konferenci Hw-list