develooper Front page | perl.perl6.users | Postings from November 2021

Re: how do I turn a real into and array of Integers?

Thread Previous | Thread Next
From:
Kevin Pye
Date:
November 1, 2021 00:51
Subject:
Re: how do I turn a real into and array of Integers?
Message ID:
97b62c86-7774-4a1c-aeca-04238d61a457@www.fastmail.com
You don't.

sqrt is a function which acts on 64-bit floating point numbers, and there's no more meaningful digits available. If you need more precision you're on your own.

On Mon, 1 Nov 2021, at 11:20, ToddAndMargo via perl6-users wrote:
> On 10/31/21 16:42, ToddAndMargo via perl6-users wrote:
>> On 10/31/21 11:20, Sean McAfee wrote:
>>> On Sun, Oct 31, 2021 at 9:08 AM Andinus via perl6-users 
>>> <perl6-users@perl.org <mailto:perl6-users@perl.org>> wrote:
>>>
>>>          put 2.sqrt.comb.grep(*.Int)>>.Int[^10].raku # 10 digits
>>>
>>>
>>> comb takes an argument that can save you a method call:
>>>
>>>      2.sqrt.comb.grep(*.Int)
>>>    ==>
>>>      2.sqrt.comb(/\d/)
>>>
>> 
>> 
>> 
>>  > 2.sqrt.comb(/\d/)
>> (1 4 1 4 2 1 3 5 6 2 3 7 3 0 9 5 1)
>> 
>> 
>>  > 2.sqrt.comb(/\d/)
>> (1 4 1 4 2 1 3 5 6 2 3 7 3 0 9 5 1)
>> 
>> 
>> 
>> :-)
>
>
> How do I get more digits out of sqrt?

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