jeudi 24 août 2017

How does Haskell determine what kind of boolean a randomly generated number is?

Consider the following two groups of code:

random (mkStdGen 1) :: (Int, StdGen) -- returns (7918028818325808681,545291967 2103410263) random (mkStdGen 1) :: (Bool, StdGen) -- returns (True,80028 40692)

random (mkStdGen 949488) :: (Int, StdGen) -- returns (9159618695640234475,587416689 2103410263) random (mkStdGen 949488) :: (Bool, StdGen) -- returns (False,1485632275 40692)

Why does 7918028818325808681 translate to True but 9159618695640234475 translates to False?




Aucun commentaire:

Enregistrer un commentaire