home / study / engineering / computer science / computer science questions and a
ID: 3739762 • Letter: H
Question
home / study / engineering / computer science / computer science questions and answers / (int)(24.768 * 100) / 100.0 = is 24.76 and (int)(24.768 * 100) / 100 = 24 but why with type ... Your question has been answered Let us know if you got a helpful answer. Rate this answer Question: (int)(24.768 * 100) / 100.0 = is 24.76 and (int)(24.768 * 100) / 100 = 24 but why with type casti... (int)(24.768 * 100) / 100.0 = is 24.76 and (int)(24.768 * 100) / 100 = 24 but why with type casting are the answers different? But how do you determine which number to exclude in final answer?
Explanation / Answer
a) (int)(24.768 * 100) / 100.0 in this scenario first calculation of 24.768 * 100 is done (24.768 * 100) = 2476.8 then it is casted to an int (int)(24.768 * 100) is 2476 then it is divided with 100.0 (a decimal number) 2476 / 100.0 is 24.76 b) (int)(24.768 * 100) / 100.0 in this scenario first calculation of 24.768 * 100 is done (24.768 * 100) = 2476.8 then it is casted to an int (int)(24.768 * 100) is 2476 then it is divided with 100 (an integer number) when two ints are used in a division, it gives an integer output 2476 / 100 is 24 it ignores the remainder
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.