11.11.2015 Взять и поделить или деление по модулю
Материал из SRNS
Korogodin (обсуждение | вклад) (→Классический %) |
Korogodin (обсуждение | вклад) (→Классический %) |
||
Строка 14: | Строка 14: | ||
{{Hider|title = Оператор % | {{Hider|title = Оператор % | ||
|content = <source lang="bash"> | |content = <source lang="bash"> | ||
− | (int(13)) % (int(- | + | (int(13)) % (int(-17)) = 13 |
− | (int(13)) % (int(- | + | (int(13)) % (int(-7)) = 6 |
(int(13)) % (int(-5)) = 3 | (int(13)) % (int(-5)) = 3 | ||
(int(13)) % (int(-1)) = 0 | (int(13)) % (int(-1)) = 0 | ||
(int(13)) % (int(1)) = 0 | (int(13)) % (int(1)) = 0 | ||
(int(13)) % (int(5)) = 3 | (int(13)) % (int(5)) = 3 | ||
− | (int(13)) % (int( | + | (int(13)) % (int(7)) = 6 |
− | (int(13)) % (int( | + | (int(13)) % (int(17)) = 13 |
− | (int(-13)) % (int(- | + | (int(-13)) % (int(-17)) = -13 |
− | (int(-13)) % (int(- | + | (int(-13)) % (int(-7)) = -6 |
(int(-13)) % (int(-5)) = -3 | (int(-13)) % (int(-5)) = -3 | ||
(int(-13)) % (int(-1)) = 0 | (int(-13)) % (int(-1)) = 0 | ||
(int(-13)) % (int(1)) = 0 | (int(-13)) % (int(1)) = 0 | ||
(int(-13)) % (int(5)) = -3 | (int(-13)) % (int(5)) = -3 | ||
− | (int(-13)) % (int( | + | (int(-13)) % (int(7)) = -6 |
− | (int(-13)) % (int( | + | (int(-13)) % (int(17)) = -13 |
− | (unsigned int(13)) % (int(- | + | (unsigned int(13)) % (int(-17)) = 13 |
− | (unsigned int(13)) % (int(- | + | (unsigned int(13)) % (int(-7)) = 13 |
(unsigned int(13)) % (int(-5)) = 13 | (unsigned int(13)) % (int(-5)) = 13 | ||
(unsigned int(13)) % (int(-1)) = 13 | (unsigned int(13)) % (int(-1)) = 13 | ||
(unsigned int(13)) % (int(1)) = 0 | (unsigned int(13)) % (int(1)) = 0 | ||
(unsigned int(13)) % (int(5)) = 3 | (unsigned int(13)) % (int(5)) = 3 | ||
− | (unsigned int(13)) % (int( | + | (unsigned int(13)) % (int(7)) = 6 |
− | (unsigned int(13)) % (int( | + | (unsigned int(13)) % (int(17)) = 13 |
+ | (int(13)) % (unsigned int(1)) = 0 | ||
+ | (int(13)) % (unsigned int(5)) = 3 | ||
+ | (int(13)) % (unsigned int(7)) = 6 | ||
+ | (int(13)) % (unsigned int(17)) = 13 | ||
+ | (int(-13)) % (unsigned int(1)) = 0 | ||
+ | (int(-13)) % (unsigned int(5)) = 3 | ||
+ | (int(-13)) % (unsigned int(7)) = 5 | ||
+ | (int(-13)) % (unsigned int(17)) = 5 | ||
+ | (unsigned int(13)) % (unsigned int(1)) = 0 | ||
+ | (unsigned int(13)) % (unsigned int(5)) = 3 | ||
+ | (unsigned int(13)) % (unsigned int(7)) = 6 | ||
+ | (unsigned int(13)) % (unsigned int(17)) = 13 | ||
</source> | </source> | ||
|hidden = 1 | |hidden = 1 |
Версия 18:00, 11 ноября 2015
|
Есть некоторая неуверенность в результатах работы функций взятия по модулю, для борьбы с которой составлена эта памятка.
Ниже представлены результаты, полученные на Oryx 161, компилятор из Xilinx SDK 2014.4 ( gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-23)).
Классический %
Оператор %
(int(13)) % (int(-17)) = 13
(int(13)) % (int(-7)) = 6
(int(13)) % (int(-5)) = 3
(int(13)) % (int(-1)) = 0
(int(13)) % (int(1)) = 0
(int(13)) % (int(5)) = 3
(int(13)) % (int(7)) = 6
(int(13)) % (int(17)) = 13
(int(-13)) % (int(-17)) = -13
(int(-13)) % (int(-7)) = -6
(int(-13)) % (int(-5)) = -3
(int(-13)) % (int(-1)) = 0
(int(-13)) % (int(1)) = 0
(int(-13)) % (int(5)) = -3
(int(-13)) % (int(7)) = -6
(int(-13)) % (int(17)) = -13
(unsigned int(13)) % (int(-17)) = 13
(unsigned int(13)) % (int(-7)) = 13
(unsigned int(13)) % (int(-5)) = 13
(unsigned int(13)) % (int(-1)) = 13
(unsigned int(13)) % (int(1)) = 0
(unsigned int(13)) % (int(5)) = 3
(unsigned int(13)) % (int(7)) = 6
(unsigned int(13)) % (int(17)) = 13
(int(13)) % (unsigned int(1)) = 0
(int(13)) % (unsigned int(5)) = 3
(int(13)) % (unsigned int(7)) = 6
(int(13)) % (unsigned int(17)) = 13
(int(-13)) % (unsigned int(1)) = 0
(int(-13)) % (unsigned int(5)) = 3
(int(-13)) % (unsigned int(7)) = 5
(int(-13)) % (unsigned int(17)) = 5
(unsigned int(13)) % (unsigned int(1)) = 0
(unsigned int(13)) % (unsigned int(5)) = 3
(unsigned int(13)) % (unsigned int(7)) = 6
(unsigned int(13)) % (unsigned int(17)) = 13
(int(13)) % (int(-7)) = 6
(int(13)) % (int(-5)) = 3
(int(13)) % (int(-1)) = 0
(int(13)) % (int(1)) = 0
(int(13)) % (int(5)) = 3
(int(13)) % (int(7)) = 6
(int(13)) % (int(17)) = 13
(int(-13)) % (int(-17)) = -13
(int(-13)) % (int(-7)) = -6
(int(-13)) % (int(-5)) = -3
(int(-13)) % (int(-1)) = 0
(int(-13)) % (int(1)) = 0
(int(-13)) % (int(5)) = -3
(int(-13)) % (int(7)) = -6
(int(-13)) % (int(17)) = -13
(unsigned int(13)) % (int(-17)) = 13
(unsigned int(13)) % (int(-7)) = 13
(unsigned int(13)) % (int(-5)) = 13
(unsigned int(13)) % (int(-1)) = 13
(unsigned int(13)) % (int(1)) = 0
(unsigned int(13)) % (int(5)) = 3
(unsigned int(13)) % (int(7)) = 6
(unsigned int(13)) % (int(17)) = 13
(int(13)) % (unsigned int(1)) = 0
(int(13)) % (unsigned int(5)) = 3
(int(13)) % (unsigned int(7)) = 6
(int(13)) % (unsigned int(17)) = 13
(int(-13)) % (unsigned int(1)) = 0
(int(-13)) % (unsigned int(5)) = 3
(int(-13)) % (unsigned int(7)) = 5
(int(-13)) % (unsigned int(17)) = 5
(unsigned int(13)) % (unsigned int(1)) = 0
(unsigned int(13)) % (unsigned int(5)) = 3
(unsigned int(13)) % (unsigned int(7)) = 6
(unsigned int(13)) % (unsigned int(17)) = 13
[ Хронологический вид ]Комментарии
Войдите, чтобы комментировать.