C++ Logo

std-proposals

Advanced search

Re: [std-proposals] TBAA and extended floating-point types

From: Paul Caprioli <paul_at_[hidden]>
Date: Tue, 26 Aug 2025 21:52:25 +0000
> The issues is there are platforms where they are different, and for the people who work on such system that difference is important and share code with people who work on systems where they are the same. That's the big advantage of using std::float64_t. It is IEEE binary64. If other people do not have systems that support std::float64_t, the code doesn't compile. That's a good thing! It is much better then silently getting wrong answers. > We also don't know the future - by defining the bits in std::float64_t we tie our hands in ways that probably won't even matter to most code that just wants a floating point value. We're not tying anyone's hands. If they just want a floating point value, they can use float or double. If they want IEEE binary64, and want to opt-in to making that a requirement for using their code, they use std::float64_t. If they want IEEE binary16, and want to opt-in to making that a requirement for using their code, they use std::float16_t. If a hardware vendor implements something novel, they can release a C++ compiler that has a type __takum16, or whatever. And, the vendor's compiler can decide what makes the most sense for their customers regarding float and double. > This argument makes std::float64_t the wrong type to use for most situations - you should use it only when you are communicating the value to some other system, or other situations where standard math is required not whatever the hardware implements. Yes, but when an IEEE type is required (not whatever the hardware implements) then std::float64_t has great value. It is not necessary to want to communicate values between systems--the algorithm may depend on the IEEE format to get the intended results.

Received on 2025-08-26 21:52:27