print hex?

Hi All,

What is the easiest way to get both print and say to print $i below in Hex?

$ p6 'my Buf $x=Buf.new(0xAE,0x5D); my int16 $i=0x5DAE; say $x; say $i;'

Buf:0x<AE 5D>
23982

Many thanks,
-T
0
perl6
2/7/2019 7:13:30 PM
perl.perl6.users 1146 articles. 0 followers. Follow

2 Replies
5 Views

Similar Articles

[PageSpeed] 52

--0000000000007bd0d4058152c2ec
Content-Type: text/plain; charset="UTF-8"

On Thu, Feb 7, 2019 at 2:14 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> What is the easiest way to get both print and say to print $i below in Hex?
>
> $ p6 'my Buf $x=Buf.new(0xAE,0x5D); my int16 $i=0x5DAE; say $x; say $i;'
>
> Buf:0x<AE 5D>
> 23982


say $i.base(16)

--0000000000007bd0d4058152c2ec
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr">On Thu, Feb 7, 2019 at 2:14 PM ToddAndMar=
go via perl6-users &lt;<a href=3D"mailto:perl6-users@perl.org">perl6-users@=
perl.org</a>&gt; wrote:<br></div><div class=3D"gmail_quote"><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid =
rgb(204,204,204);padding-left:1ex">What is the easiest way to get both prin=
t and say to print $i below in Hex?<br>
<br>
$ p6 &#39;my Buf $x=3DBuf.new(0xAE,0x5D); my int16 $i=3D0x5DAE; say $x; say=
 $i;&#39;<br>
<br>
Buf:0x&lt;AE 5D&gt;<br>
23982</blockquote><div><br></div><div>say $i.base(16)</div><div>=C2=A0</div=
></div></div>

--0000000000007bd0d4058152c2ec--
0
curt
2/7/2019 7:22:02 PM

On 2/7/19 11:22 AM, Curt Tilmes wrote:
> On Thu, Feb 7, 2019 at 2:14 PM ToddAndMargo via perl6-users 
> <perl6-users@perl.org <mailto:perl6-users@perl.org>> wrote:
> 
>     What is the easiest way to get both print and say to print $i below
>     in Hex?
> 
>     $ p6 'my Buf $x=Buf.new(0xAE,0x5D); my int16 $i=0x5DAE; say $x; say $i;'
> 
>     Buf:0x<AE 5D>
>     23982
> 
> 
> say $i.base(16)



Hi Curt,

    A thing of beauty!  Thank you!

-T

$ p6 'my Buf $x=Buf.new(0xAE,0x5D); my int16 $i=0x5DAE; say $x; say 
$i.base(0x10); print $i.base(16) ~ "\n"'

Buf:0x<ae 5d>
5DAE
5DAE
0
perl6
2/8/2019 6:36:29 AM
Reply: