scanon added a comment.

In D66836#1649846 <https://reviews.llvm.org/D66836#1649846>, @zoecarver wrote:

> > Dead link.
>
> Here: https://godbolt.org/z/AjBHYq


Yes, conversion of `numeric_limits<long long>::max` to `double` rounds to a 
value out of range for `long long`. That's not what I'm talking about. Very 
specifically, in this line:

`if (__r >= ::nextafter(static_cast<_RealT>(_MaxVal), INFINITY))`

`_MaxVal`, by construction, is representable both as `_RealT` and as `_IntT`, 
so the static_cast does not change the value (so the rounding demonstrated in 
your godbolt link doesn't create a bug). `a >= nextafter(b, INFINITY)` is 
equivalent to `a > b` for any finite floating-point `a` and `b`. So this 
condition can simply be `if (__r > static_cast<_RealT>(_MaxVal))`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66836/new/

https://reviews.llvm.org/D66836



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to