Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. calculateCRClookup = (divident)=>
  2. let
  3. // move divident byte into MSB of 32Bit CRC
  4. curByte = Number.BitwiseShiftLeft(divident,24)
  5. in
  6. List.Accumulate({0..7},
  7. curByte,
  8. (_curByte,_)=>
  9. let
  10. // if MSB set, shift left and XOR with polynomial = 0x4C11DB7
  11. then_clause = Number.BitwiseXor(Number.BitwiseShiftLeft(_curByte,1),0x4C11DB7),
  12. // else shift one bit left
  13. else_clause = Number.BitwiseShiftLeft(_curByte,1)
  14. in //if MSB set
  15. if Number.BitwiseAnd(_curByte,0x80000000)<>0 then then_clause else else_clause ),
  16. // precompute CRC32 lookup table
  17. CRC_table = List.Generate(()=>[count=0,crc=0], each [count]<256, // iterate over all possible input byte values 0-255
  18. each [count = [count]+1, crc = calculateCRClookup(count) ], each [crc])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement