51
edits
Maikmerten (talk | contribs) |
Maikmerten (talk | contribs) m (variable name fix) |
||
Line 5: | Line 5: | ||
i = (int) d; | i = (int) d; | ||
The resulting value for | The resulting value for i is 0, as casting in C will truncate any positions after the decimal point -- no rounding will occur. The same is true for JavaScript. (In JavaScript, the bitwise operators such as | will trigger an integer conversion.) | ||
To get proper rounding, following approach is often employed: | To get proper rounding, following approach is often employed: |
edits