Spec on casting to integer with smaller range than value

user1234 user1234 at 12.de
Sun Mar 29 03:59:38 UTC 2020


On Saturday, 28 March 2020 at 19:11:04 UTC, Johan wrote:
> On Saturday, 28 March 2020 at 15:23:19 UTC, Stefan Koch wrote:
>>
>> cast (ubyte)x is the same as = ((cast(uint)x) & 0xff)
>
> Where does the spec say that?
>
> -Johan

> cast(uint)x

is the trunc() that happens when casting a FP to integral type. 
https://dlang.org/spec/expression.html#cast_expressions §7.

> & 0xFF

is not specified but is the normal part of the cast uint -> ubyte.


More information about the Digitalmars-d mailing list