History

Util: word16ToSigned: fix negative numbers

Sigrid Haflínudóttir committed 8 years ago

Commit 7307f2e1 parent 51fe23c1 file · +3 −3Browse files

Showing the changes to src (1 of 1 file). Show all

Unified · Split

src/Util.hs+3−3
@@ -40,9 +40,9 @@ assign a b c at o = · 39 unmodified lines
40 40
41word16ToSigned :: Word16 -> Int41word16ToSigned :: Word16 -> Int
42word16ToSigned w =42word16ToSigned w =
43 fromIntegral $ case w `testBit` 15 of43 case w `testBit` 15 of
44 False -> w44 False -> fromIntegral w
45 True -> complement $ pred w45 True -> 0 - (fromIntegral . complement $ pred w)
46 46
47word32At :: Word16 -> BS.ByteString -> Word3247word32At :: Word16 -> BS.ByteString -> Word32
48word32At offset bs =48word32At offset bs =

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t