develooper Front page | perl.perl6.users | Postings from June 2022

Re: Easier way to load a buffer?

Thread Previous | Thread Next
From:
ToddAndMargo via perl6-users
Date:
June 11, 2022 10:04
Subject:
Re: Easier way to load a buffer?
Message ID:
e0b90a82-ce64-80e5-c6ef-0b3349888134@zoho.com
On 6/10/22 07:49, ToddAndMargo via perl6-users wrote:
> Hi All,
> 
> I am looking for an easier way to load a buffer.
> 
> I know about this way
> 
> [4] > my Buf $b=Buf.new(0x2A, 0x54, 0xFF, 0x53);
> Buf:0x<2A 54 FF 53>
> 
> I would like to do it on one big blast:
> 
> my Buf $b=Buf.new(0x2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78);
> Cannot unbox 170 bit wide bigint into native integer
> 
> But do not know the proper syntax.
> 
> Any words of wisdom?  Am I stuck with the hard way?
> 
> Many thanks,
> -T



Came up with a Raku way of doing what I want.
And dropping the need for Buf at the same time:


     > use BigRoot;
     > BigRoot.precision = 40;
     40

     > my $root5 = BigRoot.newton's-sqrt: 5;
     > $y = sprintf  $root5.base(16)
     2.3C6EF372FE94F82BE73980C0B9DB90681F

     > $y ~~ s/ $( Q[.] ) //;
     「.」

     > say $y
     23C6EF372FE94F82BE73980C0B9DB90681F

Add a loop and and some chr's and ord's and
happy camping will proceed!

:-)

-T

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About