16
LINES
< > BotCompany Repo | #1002512
// mod - better modulo that always gives positive numbers
JavaX fragment (include)
1 | // better modulo that gives positive numbers always
|
2 | static int mod(int n, int m) {
|
3 | ret (n % m + m) % m;
|
4 | }
|
5 |
|
6 | static long mod(long n, long m) {
|
7 | ret (n % m + m) % m;
|
8 | }
|
9 |
|
10 | static BigInt mod(BigInt n, int m) {
|
11 | ret n.mod(bigint(m));
|
12 | }
|
13 |
|
14 | static double mod(double n, double m) {
|
15 | ret (n % m + m) % m;
|
16 | }
|
download show line numbers debug dex old transpilations
Travelled to 19 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, elmgxqgtpvxh, gjtlkbvenryc, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, podlckwnjdmb, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, wnsclhtenguj
ID |
Author/Program |
Comment |
Date |
1376 | stefan | See https://stackoverflow.com/questions/4412179/best-way-to-make-javas-modulus-behave-like-it-should-with-negative-numbers | 2018-09-20 16:02:24 |
add comment
Snippet ID: |
#1002512 |
Snippet name: |
mod - better modulo that always gives positive numbers |
Eternal ID of this version: |
#1002512/6 |
Text MD5: |
1936192454dd7bea77ce7eb11b28000b |
Author: |
stefan |
Category: |
javax |
Type: |
JavaX fragment (include) |
Public (visible to everyone): |
Yes |
Archived (hidden from active list): |
No |
Created/modified: |
2020-11-09 11:31:06 |
Source code size: |
314 bytes / 16 lines |
Pitched / IR pitched: |
No / No |
Views / Downloads: |
1076 / 5042 |
Version history: |
5 change(s) |
Referenced in: |
[show references] |