On Tue, Jan 7, 2020 at 10:20 AM ToddAndMargo via perl6-users
<perl6-us...@perl.org <mailto:perl6-us...@perl.org>> wrote:
On 2020-01-06 22:54, ToddAndMargo via perl6-users wrote:
> Hi All,
>
> What am I doing wrong here?
>
> > my int16 $x = 0xABCD;
> -21555
>
> > say $x.base(16);
> -5433
>
> > my uint16 $y = $x.uint16;
> No such method 'uint16' for invocant of type 'Int'
> in block <unit> at <unknown file> line 1
>
> Many thanks,
> -T
Came up with a work around:
my int16 $x = 0xABCD;
my uint16 $y = $x +| 0x0000;
say $x.base(16);
say $y.base(16)
-5433
ABCD
What is the proper way?
On 2020-01-07 08:33, Brad Gilbert wrote:
my int16 $x = 0xABCD;
my uint16 $y = $x;
say $x.base(16);
say $y.base(16)
-5433
ABCD
If you just want to coerce to uint16
(my uint16 $ = $x)
say (my uint16 $ = $x).base(16)
I was looking for a way to do it after the variables were declared