GNU bug report logs -
#32252
[PATCH] %o and %x now format signed numbers
Previous Next
Reported by: Paul Eggert <eggert <at> cs.ucla.edu>
Date: Mon, 23 Jul 2018 19:14:02 UTC
Severity: normal
Tags: patch
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
hello,
I use binary-as-unsigned in my .emacs, and I saw that the help
page
said to e-mail you if I find it useful. Below is a function i
made that
displays a 32-bit two's complement of a given integer in hex. I
do a
lot of reverse-engineering of low-level programs, so it is very
useful
for me to have a quick way to see how a given integer is actually
represented in the hardware. if binary-as-unsigned wasn't
available to
make format do most of the work for me, this function would be a
lot
longer and more complicated.
(defun to-hex(value)
"convert a signed int to its 32-bit two's complement in hex
notation"
(interactive "svalue:")
(let ((binary-as-unsigned t))
(message (substring (format "%08x" (cl-parse-integer value))
-8))))
(global-set-key (kbd "C-c h") 'to-hex)
Thanks,
snickerbockers
This bug report was last modified 2 years and 322 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.