A string in C is stored as a number that contains the address in memory of the first character in the string. Any number other than zero is truthy in C. An empty string will contain the address of a single character which is the character with a value of 0 (which terminates a string). But a null pointer (which would be falsy) is actually different because it does not actually contain a valid address at all.
Idk if it's possible unironically, but some troll dev might sneak something like that into a low-level function that nobody touches and watch other people reactions when they start debugging perf issues.
Had someone doing a small test for a job interview for joining our team. For the isOdd function, a solution was used that does not use a binary operator or the commonly(?) used modulus operator. They could not reply when asked "what are your reasons to not with a modulus operator", as in they do not understand what a modulus is.
The function does work in an acceptable complexity level and is readable. That matters more. Still, the modulus has its uses in bulk data processing and encryption, tools we have to work with.
hear me out: what if we subtracted 2 from the number over and over again until its 1 or 0. like recursion! then, when it exists if its 0, then it must be even and if its 1, then its odd. and if we generate too many stack frames due to the number of function calls, we just say the number is really big.
Discrete mathematics taught me that an even number y = 2x and an odd number y = 2x+1, where x is any given number, or a specific number in the context of y.
Oh shit! No one can use a password timing hack here to know when a password exists or not. Because it's going to require an API call to chatgpt. Therefore, making the timing consistent. Genius!
but you see i took this huge effort (40 seconds) and browsed the sub OP crossposted from. that is a sub where OP is basically the only uploader for dumb slop like this post. and why is he crossposting? to promote it
239
u/uvero Dec 08 '25
if(isOdd(2)) { //...
Unfortunately, the string "No — 4 is not odd. It’s an even number because it’s divisible by 2 with no remainder." is truthy in JS.
48
u/SteroidSandwich Dec 08 '25
isOdd(5)
Output: "Here's a story about the number 5 and his quest to finding the truth"
75
u/vllado Dec 08 '25
bit of everything
49
u/obsqrbtz [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" Dec 08 '25 edited Dec 08 '25
It kinda could work
probably
12
u/Kryssz90 Dec 08 '25
I assume it would hallucinate new boolean values.
19
u/Haringat Dec 08 '25
Here's a better version:
11
u/[deleted] Dec 08 '25
Apparently people in 2020 had already forgotten the existence of "%".
4
u/FACastello Dec 08 '25
You're absolutely right!
16
u/gabor_legrady Dec 08 '25
so, Im old a boring
public static boolean isEven(int x) {return x%2==0;}public static boolean isOdd(int x) {return x%2!=0;}2
u/pskocik Dec 08 '25
Can't stop progress.
2
u/miaRedDragon Dec 08 '25
So the Mod operator is just not being used in the modern age :/ ? Good to know I guess
2
u/niclan051 Dec 08 '25
npm install is-even
2
u/mothzilla Dec 08 '25
LGTM but maybe return bool(response.content)?
2
u/oosacker Dec 09 '25
Should be async function with await
2
u/21kondav Dec 09 '25
Nobody learned about modulus because of covid education
7
u/ManRevvv Dec 08 '25
the both codes are shit honestly
1
u/JurassicJosh341 Dec 08 '25
Discrete mathematics taught me that an even number y = 2x and an odd number y = 2x+1, where x is any given number, or a specific number in the context of y.
Even then they could’ve just done a modulo of 2.
1
u/jsrobson10 Dec 09 '25
at least with the 2020 version your results are deterministic
1
u/Far-Passion4866 [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" Dec 09 '25
I could probably do this easily by seeing if a number is able to be fully divided by 2 and if it can the return false
1
u/Legendary-69420 Dec 09 '25
You forgot to use structured outputs to ensure that the model returns "yes" or "no" only
1
u/Dangerous-Mud-399 Dec 09 '25
OK. What in the actual fxxk makes you think devs in 2020 do this shit?
1
u/eggZeppelin Dec 10 '25
This is why interviews test for FizzBuzz 🙃
1
u/Fair_Necessary_2134 Dec 10 '25
It means devs were bad yesterday and today also :|
1
u/Jesus_Chicken Dec 11 '25
Oh shit! No one can use a password timing hack here to know when a password exists or not. Because it's going to require an API call to chatgpt. Therefore, making the timing consistent. Genius!
1
u/Tunfisch Dec 11 '25
Developers in 1990 if a mod 2
1
u/[deleted] Dec 11 '25
clanker wanker
1
u/xSirNC Dec 12 '25
Missing a comment saying that it checks if a number is odd
1
u/MinecraftPlayer799 Dec 13 '25
function isOdd(num) { return (num / 2).toString().includes("."); }
1
u/Redstonedust653 Pronouns: They/Them Dec 15 '25
oh god
-10
u/devor110 Dec 08 '25
kindly fuck off OP, back to your ai slop spam quarantine, thanks