On 2020-05-14 05:51, Tobias Boege wrote:
On Thu, 14 May 2020, ToddAndMargo via perl6-users wrote:
Hi All,

1) how do I get 40 or more digits out of sqrt?


Meaningful digits?

In this instance, I do not care about meaningful.  I only
care about the noise.  Just has to be repeatable.

I may have to look it up on a chart.

Not possible as sqrt uses limited precision. I think
the IEEE 754 doubles that I would suspect to be used internally are capped
way below 40 significant decimal digits.

2) how to I assist those bytes to a 40 (or more)
byte long Buf?

This obviously does not work:

my Num $x = 3.sqrt; my Buf $y = Buf.new($x)

Type check failed in initializing element #0 to Buf; expected uint8 but got
Num (1.7320508075688772e0)
   in block <unit> at <unknown file> line 1


You can convert the Num to a string and put that string into a Buf:

   Buf.new(3.sqrt.Str.encode)

That's what I'd do without any clue

I am not disclosing on purpose.  Sorry for keeping you
in the dark.

at all about who is supposed to use
this Buf. At least the buffer is about as long as the number is decimal
digits, which seems to be what you wanted?

Regards,
Tobias


my Buf $x = Buf.new(3.sqrt.Str.encode)
Buf:0x<31 2E 37 33 32 30 35 30 38 30 37 35 36 38 38 37 37 32>


Thank you!

Reply via email to