History

Util: word16ToSigned: fix negative numbers

Sigrid Haflínudóttir committed 8 years ago

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

Unified · Split

src/Util.hs+3−3
@@ -40,9 +40,9 @@ assign a b c at o = · 39 unmodified lines
4040
4141 word16ToSigned :: Word16 -> Int
4242 word16ToSigned w =
43− fromIntegral $ case w `testBit` 15 of
44− False -> w
45− True -> complement $ pred w
43+ case w `testBit` 15 of
44+ False -> fromIntegral w
45+ True -> 0 - (fromIntegral . complement $ pred w)
4646
4747 word32At :: Word16 -> BS.ByteString -> Word32
4848 word32At 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