Skip to content

Instantly share code, notes, and snippets.

@Shimuuar
Created January 11, 2020 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shimuuar/c784c9d015b885a6f37fead57ae24e36 to your computer and use it in GitHub Desktop.
Save Shimuuar/c784c9d015b885a6f37fead57ae24e36 to your computer and use it in GitHub Desktop.
IEEE754 WAT
$ ghc -fforce-recomp -O2 wat.hs && ./wat
[1 of 1] Compiling Main ( wat.hs, wat.o )
Linking wat ...
NaN
-Infinity
Infinity
-0.0
NaN
-Infinity
Infinity
-0.0
$ ghc -fforce-recomp -O0 wat.hs && ./wat
[1 of 1] Compiling Main ( wat.hs, wat.o )
Linking wat ...
-5.104235503814077e38
-3.402823669209385e38
3.402823669209385e38
0.0
-Infinity
-Infinity
Infinity
0.0
f2d :: Float -> Double
f2d = realToFrac
d2f :: Double -> Float
d2f = realToFrac
main :: IO ()
main = do
print (f2d (0/0))
print (f2d (-1/0))
print (f2d (1/0))
print (f2d (-0))
print (d2f (0/0))
print (d2f (-1/0))
print (d2f (1/0))
print (d2f (-0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment