There's probably a nicer way but I don't generally play about with this
sort of thing.

:16([~] $x.reverse.map( *.base(16) ))

It does involve lots of String manipulation, as I say. There's probably a
better way.


On Fri, 8 Feb 2019 at 06:35, Todd Chester via perl6-users <
perl6-users@perl.org> wrote:

> Hi All,
>
> I am dealing with a Buf what includes 32 bit integers, but
> they are entered somewhat backwards as view with hexedit:
>
> AE 5D 5C 72 represents the number 725C5DAE
>
> This is what I have come up with to convert this type of
> number in a buffer to and integer
>
> $ p6 'my Buf $x=Buf.new(0xAE,0x5D,0x5C,0x72); my int32 $i=$x[3] +< 0x18
> +  $x[2] +< 0x10  +  $x[1] +< 0x08  +  $x[0];  say $x; say $i.base(0x10);'
>
> Buf:0x<ae 5d 5c 72>
> 725C5DAE
>
>
> Is there a more "elegant" way to do this?
>
> Many thanks,
> -T
>


-- 
Simon Proctor
Cognoscite aliquid novum cotidie

http://www.khanate.co.uk/

Reply via email to