622
submitted 11 months ago by jroid8@lemmy.world to c/programmerhumor@lemmy.ml
you are viewing a single comment's thread
view the rest of the comments
[-] drolex@sopuli.xyz 17 points 11 months ago

Loads of beginners in this thread. Here's how it's done in the industry.

The code:

return a;

The test:

a = rand()%100+1;

It works, boss.

[-] joyjoy@lemm.ee 4 points 11 months ago* (last edited 11 months ago)

This must be a custom random function, because it's standard for random to return a float between 0-1 exclusive. Maybe you meant to multiply by 100 instead of modulo.

[-] drolex@sopuli.xyz 10 points 11 months ago
[-] Snazz@lemmy.world 5 points 11 months ago

You guys are talking about two different things. Random integer vs random float

this post was submitted on 08 Dec 2023
622 points (96.4% liked)

Programmer Humor

32549 readers
480 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS