this post was submitted on 09 Feb 2024
792 points (97.4% liked)

Programmer Humor

25671 readers
3174 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[โ€“] LastYearsPumpkin@feddit.ch -5 points 2 years ago (5 children)

But rand() is a number between 0-1, so it will never be >10

Basically this is just #define True = False

[โ€“] genfood@feddit.de 95 points 2 years ago* (last edited 2 years ago)

The C standard library function int rand(void) returns a pseudo random integer between 0 and RAND_MAX (which should be at least 2^15, depending on the actual implementation).

Depending on the distribution of the pseudo random numbers, it will be true for over > 99% of its applications.

Source: trust me bro, and C++ reference

Furthermore, there is no integer between 0 and 1, but I guess you mean a real number between 0 and 1.

load more comments (4 replies)