Test Your EQ (Engineering Quotient)

EQ #24

Suppose you are given some calibration constants for a sensor in the form of four-digit hexadecimal (16-bit) integers, and you are told that the format of these numbers is “7 integer bits and 9 fractional bits.” How would you go about converting these constants to floating-point so that you could, for example, work with them in a spreadsheet?

The direct way to convert numbers in an arbitrary fixed-point representation to the equivalent floating-point value is to figure out what the representation for “1.000” would be in the fixed-point notation and then divide the given numbers by that constant.

In this case, with 7 integer bits and 9 fraction bits, “1.000” would be represented as binary 0000001.000000000, or 0x0200. So, if you are given a constant of, say, 0x5453, just divide it by 0x0200 to find out that it represents the value “42.162.”


Don't miss out on upcoming issues of Circuit Cellar. Subscribe today!

 
 
Note: We’ve made the October 2017 issue of Circuit Cellar available as a free sample issue. In it, you’ll find a rich variety of the kinds of articles and information that exemplify a typical issue of the current magazine.


Would you like to write for Circuit Cellar? We are always accepting articles/posts from the technical community. Get in touch with us and let's discuss your ideas.

— ADVERTISMENT—

Advertise Here