Which is the most coolest operator and why is it modulo?
Which is the most coolest operator and why is it modulo?
Bit shift
Surely I'm not the only one that still reads this as "percent", even when coding
Xor
Because it's so nice.
I call it 'mod'. I heard a boomer call it 'rem' for remainder though.
What the fuck is wrong with boomers?
rest
It performs a remainder operation, not modulo. Are you sure you aren't the boomers?
Please explain what you think is the difference between the modulus and the remainder.
xor because it can emulate other bitwise operators
slide iterator --> in C
It's the same fucking thing nigger
>modulo
>not -->
-2 % 5 = -2
-2 mod 5 = 3
>that 80 IQ boomer who goes on Jow Forums and doesn't know what the difference between module and remainder is
I just did -2 % 5, it gave 3
In what language? None of the mainstream languages I know treat % that way
Just did it in a python interpreter
Cool, now try C, JS or any other language
In JS it gives -2
Neat. I wonder if this has ever created a problem in someone's work.
Probably.
why would some language handle it any other way?
Consider suicide.
Is this already a meme?
If not this might have some potential for discussions.
...
I assume that every language designer likes to do some random task slightly differently just to piss people off.
Because of people like
Why is it -2 in js, modulo for negative values or is it not modulo at all?
>-2 % 5
In Python, R. Lua and Ruby it's 3.
I dunno man, the world is all topsy turvy.
This bullshit must have made a ton of bugs.
I think in JS % means remainder and not modulo
ah ok, makes sense
That feel when the Mod command in VB is the remainder.
% was intened to be the Mod command but programmers where to IQ 80 for math.
ps
that's why all the modern languages get it right:
Anything from here: hackage.haskell.org
the goes-to operator
int x = 3;
while (x --> 0) {
printf("ayy");
}
the comma operator
int x = 2;
int y = 3;
x = (y = 4, "ayy", 5);
The Python way makes more sense mathematically, just like 0 indexing
>>=
(.) and ($)
Function composition is so elegant.
Modulo vs modulus?
>have a background in music
>Pick up programing
>Book lists operands in C and mentions that % doesn't have much use, it's just there
>My first thought was that making a tonal calculator will be piss easy with this
Remainders are algebraically defined as natural numbers between 0 and the divisor.
>In computing, the modulo operation finds the remainder after division of one number by another (sometimes called modulus).
>a mod n
>When either a or n is negative, the naive definition breaks down and programming languages differ in how these values are defined.
Fuck. I almost fell for the bait.
If it has, it's because of innumerate codemonkeys. a mod b = r with 0 < r
>while ((x--) > 0)
fuck this is cool
If you read the paper "Division and modulus for Computer Scientists", you'll find definitions for truncated, floored, and eudclidean div and mod.
microsoft.com
This page shows how inconsistent different languages are in defining the result of their various modulus operators.
Nu Jow Forums can't even tell the difference between remainder and modulo
The :? ternary operator
The comma operator is fucking gay, just have expression oriented semantics and it suddenly becomes useless
And the ternary operator. A decent language simply uses if for the same purpose.
t. boomer
r can't be |b|
That's not a modulo operator OP, that's a remainder operator. (Modulo works differently on negative numbers)
sorry, 0
best operator is the ones to pointers. * and &.