SHARE
TWEET

Untitled

a guest Jan 12th, 2017 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. convertNBytesLen :: [Word8] -> Int32
  2. convertNBytesLen = foldr accum 0
  3.   where accum bs a = 256 * a + fromIntegral bs
  4.  
  5.  
  6. bsToDouble :: S.ByteString -> Int -> Double
  7. bsToDouble bs n = if intV >= 0
  8.                    then fromIntegral intV / 2147483647
  9.                    else - (fromIntegral intV / (-2147483648))
  10.   where intV = convertNBytesLen (S.unpack bs) `shift` (32 - 8 * n)
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top