C++ Logo

std-proposals

Advanced search

Re: Reserve good keywords for floating point types

From: Andrey Semashev <andrey.semashev_at_[hidden]>
Date: Tue, 15 Oct 2019 19:34:09 +0300
On 2019-10-15 19:12, Tony V E via Std-Proposals wrote:
>
> Yes, obviously there are cases where format matters. They tend to be
> when communicating to other devices/computers.
> I need to give the correct format to my projectors. But that's 1% of my
> code, not 99%.

But you do care about precision of your internal calculations, don't
you? You probably also care about denormals and special values? You
probably assume that double is binary64, but that is not guaranteed by
the standard, is it? So, your assumption is unfounded, even if it holds
true in your particular environment.

The same thing is with integers. The standard doesn't say much about
int, so you can't be confident about which integer values are
representable by int and which are not. This is especially sad, given
that signed overflow is UB. So, basically anything beyond a toy project
should use intN_t in order to have behavior that can be reasoned about,
especially in corner cases.

Received on 2019-10-15 11:36:27