1 // RUN: %clang_cc1 -verify %s
3 // expected-no-diagnostics
6 * reliable integer division
9 _Static_assert(59 / 4 == 14, "we didn't truncate properly");
10 _Static_assert(59 / -4 == -14, "we didn't truncate properly");
11 _Static_assert(-59 / 4 == -14, "we didn't truncate properly");
12 _Static_assert(-59 / -4 == 14, "we didn't truncate properly");
14 // Might as well test % for the quotient.
15 _Static_assert(59 % 4 == 3, "we didn't truncate properly");
16 _Static_assert(59 % -4 == 3, "we didn't truncate properly");
17 _Static_assert(-59 % 4 == -3, "we didn't truncate properly");
18 _Static_assert(-59 % -4 == -3, "we didn't truncate properly");
20 // Test the idiom for rounding up.
21 _Static_assert((59 + (4 - 1)) / 4 == 15, "failed to 'round up' with the usual idiom");
22 _Static_assert((59 + (4 - 1)) % 4 == 2, "failed to 'round up' with the usual idiom");