3 ms·
Why is there no float type with linear precision?
by bullen 5y ago
Why is there no float type with linear precision?
- adgjlsfhk1 5y agothat's called fixed point. there isn't hardware for it because it is cheap to make in software using integer math.
- bullen 5y agoBut 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?
- adgjlsfhk1 5y agoyour add is just an integer add. your multiply is a mul_hi, 2 shifts, 1 add and 1 mul.
- bullen 5y agoI know some of those words, but still I'm curious as to why OpenGL has not explored fixed for 3D graphics?
- adwn 5y agoHaving 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.
- mhh__ 5y agoAre you asking if integer SIMD exists? (It does)
- djmips 5y agoSome DSP chips had hardware for fixed point. I think it's a shame that C never added support for fixed point.
- kevin_thibedeau 5y agoThere 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.
- bullen 5y agoBut the stdfix does not take advantage of SIMD style acceleration right?