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-us...@perl.org> wr
On Fri, Feb 8, 2019 at 7:36 AM Todd Chester via perl6-users <
perl6-us...@perl.org> wrote:
> 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
If you have a new enough version of Rakudo:
my Buf $x=Buf.new(0xAE,0x5D,0x5C,0x72);
my int32 $i = $x.read-int32(0,LittleEndian);
say $i.base(16);
# 725C5DAE
On Fri, Feb 8, 2019 at 12:35 AM Todd Chester via perl6-users
wrote:
>
> Hi All,
>
> I am dealing with a Buf what includes
Ooo. Nice.
On Fri, 8 Feb 2019, 17:55 Brad Gilbert If you have a new enough version of Rakudo:
>
> my Buf $x=Buf.new(0xAE,0x5D,0x5C,0x72);
>
> my int32 $i = $x.read-int32(0,LittleEndian);
>
> say $i.base(16);
> # 725C5DAE
>
> On Fri, Feb 8, 2019 at 12:35 AM Todd Chester via per
The `=` infix operator is a meta operator.
That means it takes an infix operator as a sort of "argument".
There is no `+=` operator, it is just the `=` operator combined with
the `+` operator.
$a += 2;
$a [+]= 2; # more explicitly take the + operator as an argument to
the = operator
So
>>
>> Hi All,
>>
>> Is this the only way to shift left?
>>
>> $i = $i +< 0x01
>>
>> $ p6 'my int32 $i=0x5DAE; say $i.base(0x10); $i = $i +< 0x01; say
>> $i.base(0x10);'
>>
>> 5DAE
>> BB5C
>>
>>
>> Does we have any of those fancy += ~= ways of doing it?
>>
>> Many thanks,
>> -T
On 2/8/
On 2/7/19 10:35 PM, Todd Chester via perl6-users 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 b
On 2/8/19 2:34 AM, Simon Proctor wrote:
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.
Thank you!
On 2/8/19 2:59 AM, The Sidhekin wrote:
The "elegant" way I'd do it, is using unpack():
https://docs.perl6.org/routine/unpack
It's experimental, so a declaration is needed, but Buf does Blob, so
otherwise, it's straight to the point:
$ perl6 -e 'use experimental :pack; my Buf
$x=Buf.n
On 2/8/19 9:54 AM, Brad Gilbert wrote:
If you have a new enough version of Rakudo:
my Buf $x=Buf.new(0xAE,0x5D,0x5C,0x72);
my int32 $i = $x.read-int32(0,LittleEndian);
say $i.base(16);
# 725C5DAE
Thank you!
Unpack is very useful if you have multiple items you want to unpack, and if
you're familiar with the Perl 5 unpack then there's the P5pack module
(which isn't a full implementation of Perl 5's unpack, but is useful for
simpler things). If you want to unpack something from the middle of a Buf
or Blo
On 2/8/19 1:37 PM, Kevin Pye wrote:
Unpack is very useful if you have multiple items you want to unpack, and
if you're familiar with the Perl 5 unpack then there's the P5pack module
(which isn't a full implementation of Perl 5's unpack, but is useful for
simpler things). If you want to unpack s
On 2/8/19 1:37 PM, Kevin Pye wrote:
Unpack is very useful if you have multiple items you want to unpack, and
if you're familiar with the Perl 5 unpack then there's the P5pack module
(which isn't a full implementation of Perl 5's unpack, but is useful for
simpler things). If you want to unpack s
the perl6-native "read-int32" or native-but-experimental "unpack" are the
natural answers- they map well from problem to answer! There's a good
example of perl6's pack in this thread.
read-int32 was mentioned without an example so...
my Buf $x = Buf.new(0x00, 0xFF, 0x88, 0xAE,0x5D,0x5C,0x72);
Bu
The next release of Rakudo with have read-int32.
To use it now you would need to build from the git repository, I think.
On Fri, Feb 8, 2019 at 7:56 PM yary wrote:
>
> the perl6-native "read-int32" or native-but-experimental "unpack" are the
> natural answers- they map well from problem to answ
15 matches
Mail list logo