float.sizeof should be 4
Timon Gehr
timon.gehr at gmx.ch
Sun Sep 22 14:59:36 UTC 2024
On 9/22/24 14:59, Steven Schveighoffer wrote:
> Not `4LU`.
>
> For the billionth time while porting raylib to D, I'm having to replace
> `n*float.sizeof` with `n*int(float.sizeof)` because otherwise, it
> doesn't fit into the `int` I'm assigning it to.
>
> Why isn't it just 4? 4 will convert to any width you want. It does not
> poison integer multiplications or additions.
>
> The chances that `T.sizeof > int.max` is near zero. And even if it did,
> making it the same as a number literal would just work -- it would
> become `size_t` if it was too big.
>
> -Steve
Well, the point of contention is not that `float.sizeof > int.max`.
Rather, `n*float.sizeof` could be bigger than `int.max`.
More information about the Digitalmars-d
mailing list