Is there any reason why arithmetic operation on shorts and bytes return int?
Simen Kjaeraas
simen.kjaras at gmail.com
Wed Dec 12 00:23:35 PST 2012
On 2012-09-12 00:12, js.mdnq <js_adddot+mdng at gmail.com> wrote:
> struct bbyte {
> byte value;
> ...
> }
>
> bbyte a; bbyte b;
>
> b = a + b; // uses bbyte's operators and casts to do the computation and
> assignment but then returns a bbyte instead of an int.
>
> You should have no problems implicitly converting bbyte to built in
> types or built in types to bbyte.
Not entirely true. Converting from bbyte to built-in works, but these
are to my knowledge currently impossible:
void foo(bbyte b);
byte b;
foo(b); // No conversion.
bbyte bar( ) {
byte b;
return b;
}
--
Simen
More information about the Digitalmars-d
mailing list