A nice feature of viewing binary files with hexl-mode is it displays the equivalent ASCII values to the right of your hexidecimal lines.

Is there a way to make hexl-mode treat hex values as floats, doubles, or some other format instead of ASCII? If not, is there a way to easily do the conversion on a line or region basis and display the result in the same buffer?

Suggestions for modes besides hexl-mode are fine, but I would prefer to stick to the built-in modes if it doesn't require too much .emacs configuration.

  • You would really need to know how the value was written. For example, there are many different float point standards (IEEE has three popular ones for two, four and eight bytes floats). But some formats may choose to compress numbers using some algorithm, of course they could also write it assuming big or little endian reader. There are also less orthodox float point formats (with exponent being base 10 for eg.) It would usually make more sense to interpret binary data as some specific format.
    – wvxvw
    Commented Oct 12, 2014 at 17:17
  • That is exactly what I am asking for - binary data interpreted in a variety of data formats. Commented Oct 13, 2014 at 14:38

3 Answers 3


I think the most simple answer is "no, there is no way to make hexl-mode do that".

Mostly because hexl-mode is by nature very limited in what it can and can't do (or more specifically, to let it do other things, you'd have to change it substantially).

I'm not sure what you mean by "display hex values as floats", but if you mean "take 4-byte chunks and treat them as 32-bit floats", then I think the best way might be to do something like what nhexl-mode does. It's not going to be a 2-line change, though, since you're going to have to write by hand the conversion from 4-byte chunks to a float.

  • 1
    This seems like a ripe territory for a new mode since Linux lacks a well rounded hex viewer. Hopefully someone with better elisp skills than I will step up to the plate. Until then I will do as you say and write little functions myself. Commented Oct 24, 2014 at 6:46

This answer doesn't really involve emacs per se, but you can use the Unix or GNU od command to solve your problem. In particular, od -f is probably what you are looking for regarding floats and od -t fD will format doubles. You could always use M-! to get the command output into a buffer if you really need it inside of emacs. ;)


Based on @b4hand's solution, I wrote a simple script to view the content of a file in multi-byte format.

(defun view-byte-array (format)
  "View the current file in od dump"
  (interactive "sFormat Code: ")
  (let* (
     ($outputbuffer "*od dump*")
         ($fname (buffer-file-name))
    (setq $cmdStr (concat "od --endian=big -t " format " \""   $fname "\" &"))
    (message "Running %s" $cmdStr)
    (shell-command $cmdStr $outputbuffer)

Demo with 4-byte uint32:

unint32 od dump

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.