On Wednesday, 30 November 2022 at 03:07:44 UTC, thebluepandabear
wrote:
I am curious as to what formula the D compiler uses for
calculating 'overflowed' values, if such thing exists? :)
Regards,
thebluepandabear
**Source:**
http://ddili.org/ders/d.en/cast.html?#ix_cast.arithmetic%20conversion
1. If one of the values is real, then the other value is
converted to **real**
2. Else, if one of the values is **double**, then the other value
is converted to **double**
3. Else, if one of the values is **float**, then the other value
is converted to **float**
4. Else, first integer promotions are applied according to the
table above, and then the following rules are followed:
**A.** If both types are the same, then no more steps needed
**B.** If both types are signed or both types are unsigned, then
the narrower value is converted to the wider type
**C.** If the signed type is wider than the unsigned type, then
the unsigned value is converted to the signed type
**D.** Otherwise the signed type is converted to the unsigned type
SDB@79