jroid8@lemmy.world to Programmer Humor@lemmy.ml · 11 months agoknow the features of your languagelemmy.worldimagemessage-square145fedilinkarrow-up1645arrow-down124
arrow-up1621arrow-down1imageknow the features of your languagelemmy.worldjroid8@lemmy.world to Programmer Humor@lemmy.ml · 11 months agomessage-square145fedilink
minus-squaredrolex@sopuli.xyzlinkfedilinkarrow-up18arrow-down1·11 months agoLoads 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.
minus-squareunalivejoy@lemm.eelinkfedilinkEnglisharrow-up6arrow-down2·edit-211 months agoThis 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.
minus-squaredrolex@sopuli.xyzlinkfedilinkarrow-up11arrow-down1·11 months agoI think for once I didn’t fuck up. https://cplusplus.com/reference/cstdlib/rand/
minus-squareSnazz@lemmy.worldlinkfedilinkarrow-up5·11 months agoYou guys are talking about two different things. Random integer vs random float
Loads of beginners in this thread. Here’s how it’s done in the industry.
The code:
The test:
It works, boss.
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.
I think for once I didn’t fuck up.
https://cplusplus.com/reference/cstdlib/rand/
You guys are talking about two different things. Random integer vs random float