Start trying to generate shift code.

This commit is contained in:
2019-11-04 17:08:16 -08:00
parent ed07a0855d
commit ba587cb37f
4 changed files with 209 additions and 1 deletions

View File

@@ -10,6 +10,20 @@ generateNum g size =
x' = x `mod` (2 ^ size)
in (x', g')
modulate :: (Integral a, Integral b) => a -> b -> Integer
modulate x size = x' `mod` (2 ^ size')
where
x', size' :: Integer
size' = fromIntegral size
x' = fromIntegral x
modulate' :: (Num a, Integral a, Integral b) => a -> b -> Integer
modulate' x size = signum x' * ((abs x') `mod` (2 ^ size'))
where
x', size' :: Integer
size' = fromIntegral size
x' = fromIntegral x
showX :: Integer -> String
showX x | x < 0 = "-" ++ showX (abs x)
| otherwise = showHex x ""