vendredi 28 juillet 2023

Why do most `rdrand` implementations use signed integers as return value instead of an unsigned integer?

While browsing rdrand implementations (e.g. here) in C for curiousity, I've stumbled upon a detail I could not figure out myself.

Why do most rdrand implementations actually return a signed integer, instead of an unsigned integer? Since unsigned integers wrap around and cannot overflow, why use signed integers in random number generation in fist place, when it's the signed integers that are prone to integer overflows? Wouldn't it be more safe to return an unsigned integer?




Aucun commentaire:

Enregistrer un commentaire