You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rand() returns a random 31-bit integer packed into a 32-bit integer (whose sign bit is always zero). The positions of the extracted bits should then be 0, ..., 30. However, by setting k=30, flip_pos = k, and flip_pos --, we only ever extract bits the bits at locations 0, ..., 29.
Also the code can be made more general to determine k automatically from limits.h and RAND_MAX.
The text was updated successfully, but these errors were encountered:
fast-loaded-dice-roller/src/c/flip.c
Lines 14 to 25 in 19d30ab
rand()
returns a random 31-bit integer packed into a 32-bit integer (whose sign bit is always zero). The positions of the extracted bits should then be 0, ..., 30. However, by settingk=30
,flip_pos = k
, andflip_pos --
, we only ever extract bits the bits at locations 0, ..., 29.Also the code can be made more general to determine
k
automatically fromlimits.h
andRAND_MAX
.The text was updated successfully, but these errors were encountered: