Energy & Power · Study deck

Fixed-Point Arithmetic

Picture a battery sensor that stays awake to calculate a value its small processor could handle with scaled integers.

Battery Bruno is your guide for this deck.

optimizationfixedpoint
Battery Bruno, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Explain: In the signed Qn.m convention used here, one bit is the sign, n bits are the integer magnitude, and m bits are fractional; the total width is 1+n+m bits.
  • Explain: That contrast is the visual's teaching load: Fixed-point conversion workflow from range survey and error budget through Q-format choice, safe implementation, boundary tests, and energy remeasurement.
  • Explain: In other words, no-panel fixed-point validation gates: range survey, golden vectors, overflow tests, error budget, target timing, and full-cycle energy evidence.
  • Convert between real values, scaled integers, and engineering units.
iotclass.org

Major section

Start With a Floating-Point Cost You Can Avoid

A faster result is useful only if its error remains safe.

  • Firmware means the software stored on the device.
  • Duty cycle means the share of time a device spends active instead of asleep.
  • This runway does not prove that fixed-point arithmetic is always better.

Picture a battery sensor that stays awake to calculate a value its small processor could handle with scaled integers. A faster result is useful only if its error remains safe.

Picture a battery sensor that stays awake to calculate a value its small processor could handle with scaled integers.

Why it matters

Fixed-point work may reduce that active share.

iotclass.org

Major section

Q-Format Model

In the signed Qn.m convention used here, one bit is the sign, n bits are the integer magnitude, and m bits are fractional; the total width is 1+n+m bits.

  • The separate 2^n-2 label adds a distinct review condition, preventing the first two stages from being accepted on their own.
Q-format fixed-point representation showing sign/integer bits, fractional bits, scale factor, resolution, and stored integer.
Q-format fixed-point representation showing sign/integer bits, fractional bits, scale factor, resolution, and stored integer.
iotclass.org

Major section

Validation Gates

Fixed-point arithmetic changes numerical behavior.

  • In other words, no-panel fixed-point validation gates: range survey, golden vectors, overflow tests, error budget, target timing, and full-cycle energy evidence.
  • Any required value cannot be represented with margin.
  • Error changes decisions, alarms, control output, or classification.
  • Intermediate values cannot wrap silently.
Fixed-point validation gates showing range survey, golden vectors, overflow tests, error budget, target timing, and full-cycle energy evidence.
Fixed-point validation gates showing range survey, golden vectors, overflow tests, error budget, target timing, and full-cycle energy evidence.
iotclass.org

Major section

Cycles Become Active Time Becomes Energy

They expose the two conditions that the surrounding argument must keep together.

  • That contrast is the visual's teaching load: Fixed-point conversion workflow from range survey and error budget through Q-format choice, safe implementation, boundary tests, and energy remeasurement.
Fixed-point conversion is not just a code rewrite; it starts with range and error evidence, then ends with boundary tests and a new energy measurement.
Fixed-point conversion is not just a code rewrite; it starts with range and error evidence, then ends with boundary tests and a new energy measurement.
iotclass.org

Deck summary

Key takeaways

A faster result is useful only if its error remains safe.

  • In the signed Qn.m convention used here, one bit is the sign, n bits are the integer magnitude, and m bits are fractional; the total width is 1+n+m bits.
  • Fixed-point arithmetic changes numerical behavior.
  • They expose the two conditions that the surrounding argument must keep together.
iotclass.org

Retrieval practice

Recall check 1 of 5

Battery Bruno says: answer from memory, then check your reasoning.

Q1A firmware value is stored as fixed point. Which conversion rule preserves its engineering meaning?

AApply the documented scale and rounding, range-check the result, and retain unit and scale metadata.
BCopy the floating value into an integer and discard its physical unit and scale.
CDivide by the estimated scale and save the result because that scale keeps values in the valid range.
DInterpret stored bits as physical units without applying the documented conversion.
Show answer

Answer: A Scaling maps physical values to codes; rounding and a range policy keep the stored result meaningful.

iotclass.org

Retrieval practice

Recall check 2 of 5

Battery Bruno says: answer from memory, then check your reasoning.

Q2Two temperature readings in °C use different fixed-point scales. What should happen before they are added?

AIgnore scale metadata because both stored values are integers.
BRename the result without correcting its fixed-point units.
CConvert to one scale, then check the summed value's range.
DAdd raw stored integers before checking their two scales.
Show answer

Answer: C First confirm the same physical unit, then convert to a common scale and check the sum’s range.

iotclass.org

Retrieval practice

Recall check 3 of 5

Battery Bruno says: answer from memory, then check your reasoning.

Q3What should drive the choice of integer and fractional bits in a fixed-point format?

AMeasured value range, required precision, intermediate width.
BAlways choose the format with the most fractional bits.
CAlways use the same format for every value in the program.
DChoose the format only from the processor clock speed.
Show answer

Answer: A Fixed-point design starts with numeric requirements and validation evidence.

Q4What integer and fractional bit allocation trades numeric range against resolution?

ARange survey
BOperation
CQ-format
DValidation
Show answer

Answer: C Its integer and fractional bits trade representable range against resolution.

iotclass.org

Retrieval practice

Recall check 4 of 5

Battery Bruno says: answer from memory, then check your reasoning.

Q5Why does a floating-point multiply cost far more energy than a fixed-point multiply on a Cortex-M0+ sensor node?

ASoft-float uses many active cycles; fixed-point uses integer hardware.
BThe FPU is present but clock-gated until the first multiply finishes.
CFloating-point storage bits leak more battery than integer storage bits.
DFixed-point needs a radio wakeup before each integer multiply.
Show answer

Answer: A Without an FPU, floats are emulated in software and take many cycles; fixed-point uses the integer multiplier in a few cycles.

iotclass.org

Retrieval practice

Recall check 5 of 5

Battery Bruno says: answer from memory, then check your reasoning.

Q6A Cortex-M4F design with a single-precision FPU still shows high compute energy in a hot loop that uses floats. What is a likely cause?

AThe FPU makes single-precision float slower than software integer math.
BFixed-point has replaced float in the hot loop and is raising current.
CAccidental double math is falling back to software emulation.
DThe processor clock is too low, so every float becomes double.
Show answer

Answer: C The M4F FPU accelerates only single precision.

iotclass.org

Print reference

Answers 1 of 2

Answer key.

  1. A · Scaling maps physical values to codes; rounding and a range policy keep the stored result meaningful.
  2. C · First confirm the same physical unit, then convert to a common scale and check the sum’s range.
  3. A · Fixed-point design starts with numeric requirements and validation evidence.
  4. C · Its integer and fractional bits trade representable range against resolution.
  5. A · Without an FPU, floats are emulated in software and take many cycles; fixed-point uses the integer multiplier in a few cycles.
iotclass.org

Print reference

Answers 2 of 2

Answer key.

  1. C · The M4F FPU accelerates only single precision.
iotclass.org