4 ms·
> typedef float f32; > typedef double f64; Assuming float is 32 bits and double is 64 bits sounds like a foot-gun. OpenCV defines a float16_t [0], CUDA
by bArray 3y ago
> typedef float f32;
> typedef double f64;
Assuming float is 32 bits and double is 64 bits sounds like a foot-gun. OpenCV defines a float16_t [0], CUDA implements half-precision floats [1], micro-controllers implement whatever they want.
C++23 introduces fixed width floating-point types [2], but not aware of any way to enforce this in C. What I would suggest it to have a macro to check data is not lost at compile time.
Generally I agree with others, it might be better to leave some of these things as default for readability, even if it is not concise.
[0] https://docs.opencv.org/4.x/df/dc9/classcv_1_1float16__t.html https://docs.opencv.org/4.x/df/dc9/classcv_1_1float16__t.htm...
[1] https://docs.nvidia.com/cuda/cuda-math-api/group__CUDA__MATH____HALF__MISC.html https://docs.nvidia.com/cuda/cuda-math-api/group__CUDA__MATH...
[2] https://en.cppreference.com/w/cpp/types/floating-point https://en.cppreference.com/w/cpp/types/floating-point
- CodeArtisan 3y agogcc has _Float<size> types typedef _Float32 f32; typedef _Float64 f64; https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html
- sigsev_251 3y agoIt's not just gcc, they are in the C23 standard along with the _Decimal<size> types.