On Saturday, 5 June 2021 at 00:24:01 UTC, someone wrote:

On Saturday, 5 June 2021 at 00:24:01 UTC, someone wrote:
? 0 : cast(ushort)(this.pintBottom1 - 1); }

It looks like you’re being caught by D’s arithmetic conversions: https://dlang.org/spec/type.html#usual-arithmetic-conversions

“If the signed type is larger than the unsigned type, the unsigned type is converted to the signed type.”

Your pint variables are ushorts but the 1 you subtract is an int literal so the result gets promoted to an int.

Also, I don’t believe there is an unambiguous way to write a ushort literal: https://dlang.org/spec/type.html#basic-data-types

You should be ok with “u” if the function’s return is ushort. The compiler should be able to figure it out from there. I’m hoping I’m not wrong there as I haven’t tried it myself.

Reply via email to