Johan
Johan

Reputation: 20763

What is the datatype used in the DS18B20 called?

In the temperature chip DS18B20 the temperature value is stored with 12bit, where the integer part is 2 complement and the lower 4 bits is the decimal part.

The layout is like this:

  Bit 11     Signed
  Bit 10..4  2^7  .. 2^0
  Bit  3..0  2^-1 .. 2^-3

More info DS18B20.pdf page 4

So to represent the number 0.5 we set bit 3 since 2^-1 is 0.5. And to represent the number 0.75 we ser bit 3 and 2 since 2^-1 + 2^-2 = 0.75.

What is this type of representation called in mathematical and computer science terminology?

Upvotes: 0

Views: 120

Answers (1)

mattnedrich
mattnedrich

Reputation: 8052

It looks like fixed point notation: http://en.wikipedia.org/wiki/Fixed-point_arithmetic

Perhaps a better link: http://chortle.ccsu.edu/AssemblyTutorial/Chapter-29/ass29_7.html

Upvotes: 1

Related Questions