this post was submitted on 09 Feb 2024
482 points (100.0% liked)

Programmer Humor

418 readers
3 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 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[โ€“] TwilightKiddy@programming.dev 1 points 7 months ago (1 children)

rand() generates a number from 0 to a constant defined in stdlib, which usually corresponds to the architechture of your compiler. So, for 32 bit systems (assuming all the software in the line is 32 bit, too) it will be 2^31-1 = 2 147 483 647, as 1 bit in integers is reserved for negative numbers and 1 number is 0.

Though, by design it is guaranteed to be at least 32767, which is a value for 16 bit integers.

[โ€“] lhamil64@programming.dev 1 points 7 months ago

Oh good to know. I googled it and got that 32767 number but it did say "guarantee to be at least 32767"