mirror of
https://github.com/GaloisInc/cryptol.git
synced 2024-11-09 17:15:06 +03:00
Merge pull request #1053 from GaloisInc/issue1049
Fix the binary encoding of floating-point values.
This commit is contained in:
commit
7eba2307b4
@ -234,7 +234,7 @@ floatToBits e p bf = (isNeg `shiftL` (e' + p'))
|
||||
case num of
|
||||
Zero -> (0,0)
|
||||
Num i ev
|
||||
| ex == 0 -> (0, i `shiftL` (p' - m -1))
|
||||
| ex <= 0 -> (0, i `shiftL` (p' - m -1 + fromInteger ex))
|
||||
| otherwise -> (ex, (i `shiftL` (p' - m)) .&. pMask)
|
||||
where
|
||||
m = msb 0 i - 1
|
||||
|
2
tests/issues/issue1049.icry
Normal file
2
tests/issues/issue1049.icry
Normal file
@ -0,0 +1,2 @@
|
||||
:m Float
|
||||
:exhaust (\x -> (y != y \/ x == fpToBits y where y = fpFromBits x : Float16))
|
6
tests/issues/issue1049.icry.stdout
Normal file
6
tests/issues/issue1049.icry.stdout
Normal file
@ -0,0 +1,6 @@
|
||||
Loading module Cryptol
|
||||
Loading module Cryptol
|
||||
Loading module Float
|
||||
Using exhaustive testing.
|
||||
Testing... Passed 65536 tests.
|
||||
Q.E.D.
|
Loading…
Reference in New Issue
Block a user