Home:ALL Converter>Name of fixed-point/integer representation with alternate unit of measurement

Name of fixed-point/integer representation with alternate unit of measurement

Ask Time:2021-09-13T17:05:08         Author:Matjaž

Json Formatter

When processing signals and sensor values in embedded C, we can usually choose between representing the values in floating-point (e.g. IEEE 754) or fixed-point, the latter often preferred when no floating-point unit is available, as it's my case.

I was wondering what is the name of a solution/pattern where we use just plain integers to represent the sensor value without decimals because we simply change the unit of measurement the value is represented in the unit of the maximum accuracy.

Example

Let's assume I have a distance-measuring sensor (like a proximity sensor) with millimetre-accuracy. An example output would be 1.234 m. I have the following choices to store the output distance measurement:

  1. floating-point, representing the distance in metres
  2. fixed-point, representing the distance in metres, with 3 decimal places for the millimetres
  3. integer, representing the distance in millimetres instead of metres

I only need to take care of having large-enough integers when doing arithmetics with the third option to avoid overflows. For example: computing the area of a rectangle measured by two sensors is done by multiplying two distances in millimetres a*b and this requires twice as many bits, because the unit is also squared: mm^2.

Non-SI cases

The same "third option" representation can be used for more complex stuff than just SI-prefixes, like a int32_t representing k multiples of sqrt(2) instead of saving k*sqrt(2) into a float directly, that is: storing int32_t k_foo = 3; instead of float foo = 4.2426405f;.

My question

Is there an official name for the "third option" in data representation? It's like fixed-point with no decimal places but with a non-standard unit. The "decimal places" are implicit in the used measurements unit. I have a hard time documenting this (kind of stupid) solution without a name.

Author:Matjaž,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/69160025/name-of-fixed-point-integer-representation-with-alternate-unit-of-measurement
yy