3 ms·
I'm not liking the fixed-point types. I'd rather see the ability to place an attribute on a floating-point variable that would inform the compiler that fixed-p
by tropo 11y ago
I'm not liking the fixed-point types.
I'd rather see the ability to place an attribute on a floating-point variable that would inform the compiler that fixed-point might be suitable. You'd specify the requirements that need to be met, and the compiler would choose the fastest format for the current architecture. That format could be fixed-point, decimal float, IEEE float, or something weirder.
For example, your requirements could include: minimum magnitude, maximum magnitude, minimum value, maximum value, maximum additive error, maximum multiplicative error, signed zero needed or not, NaN signed/unsupported/unsigned, infinity distinct from NaN and/or the largest number, etc.
You say what you need for correctness, and the compiler makes it happen.
- _kst_ 11y agoFixed-point and floating-point types have very different behavior. I can't think of a case where I'd want to let the compiler decide which one to use.
- tropo 11y agoNo, normally what people desire of a fixed-point representation is a subset of a floating-point representation. Most fixed-point stuff is prototyped as floating-point, then painfully converted into a mess of nasty macros. Ideally there would be assertions to protect against failure due to the limited functionality of the fixed-point type, but probably you don't bother. It's not maintainable. We should be able to take that prototype, mark it up with hints for the compiler, and then build with fixed-point enabled.