negative numbers to hexdecimal
8 views (last 30 days)
Show older comments
How can i transform a negative number like 0,2378 into hexdecimal? The function num2hex and dec2hex, they don´t work! and the bitcmp(..) also doesn´t work.
thanks for helping.
5 Comments
Samuel Gray
on 30 Dec 2021
yeah, it works but what did you actually get...
hex notation is usually reserved for integers.
there is num2hex and dec2hex
the first will give you the 16-character representation,
the latter has a 2nd input that lets the user set the # of characters in the returned value
num2hex will work with both positive and negative reals.
Walter Roberson
on 30 Dec 2021
Hex notation since at least the IBM 360 has been used to show the bits actually in memory, distinct from the interpretation that the bits are going to be given by the program and instructions. Instructions, characters, integers, floating-point numbers: hex to show you the real bits. Especially for those days when you suspect that the programming language or disassembler are treating a value incorrectly (which did happen...)
Answers (0)
See Also
Categories
Find more on Numeric Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!