Common type of ubyte and const ubyte is int
Steven Schveighoffer
schveiguy at gmail.com
Thu May 2 16:16:23 UTC 2024
On Thursday, 2 May 2024 at 12:34:03 UTC, Dom DiSc wrote:
>
> Yes, those rules are often cumbersome. The promotions should
> look more like:
> ```
> ubyte > ushort > uint > ulong
> v v v v
> byte > > short > > int > > long >
> v v v
> float > double > real
> ```
> To find the common type, go to the crossing of the rightmost
> and the downmost of the types
> and if there is no type at this point, go one further right or
> if that is not possible go one further down. This works for all
> numeric basic types.
> E.g. common(byte, ubyte) = short,
> common(float, uint) = double,
> common(long, ulong) = real
But let's take a step back. As far as integrals, they are *the
same type*, it's just that one is const and one is not.
There is no rule that says if the types are the same type except
for type modifiers, what should happen. I think there should be.
The result is very unexpected.
-Steve
More information about the Digitalmars-d
mailing list