Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. uint32_t read_magic(FILE *obj_file, int offset)
  2. {
  3. uint32_t magic;
  4. fseek(obj_file, offset, SEEK_SET);
  5. fread(&magic, sizeof(uint32_t), 1, obj_file);
  6. printf("%x\n", magic);
  7. return magic;
  8. }
  9. gives feedfacf as expected.
  10.  
  11. With bitstring:
  12.  
  13. let () =
  14. let file = Sys.argv.(1) in
  15. let b = Bitstring.bitstring_of_file file in
  16. bitmatch b with
  17. | { magic : 32 : littleendian} -> Printf.printf "%x\n" (Int32.to_int magic)
  18. | { _ } -> ()
  19.  
  20. getting 7ffffffffeedfacf
  21. where I understand the 7ffffff means NaN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement