← Back to context

Comment by bullen

4 years ago

Why is there no float type with linear precision?

that's called fixed point. there isn't hardware for it because it is cheap to make in software using integer math.

  • But wouldn't it be sweet to have SIMD acceleration for fixed point?

    Or is that something you can do with integers and SIMD today?

    Say 4x4 matrix multiplication?

    • Having implemented a nested PID controller using fixed-point arithmetic in an FPGA, I can tell you that fixed-point is a pain in the ass, and you only use it when floating-point is too slow, too large (in terms of on-chip resources), or consumes too much power, or when you really need to control the precision going into and out of an arithmetic operation.

  • Some DSP chips had hardware for fixed point. I think it's a shame that C never added support for fixed point.

    • There was a draft and GCC supports it in stdfix.h. The downside is that the types have limited integer range since they're tailored for DSP applications where values are kept scaled between +/-1.0.

      1 reply →