Hello ToddAndMargo,

The answer to your question depends on how the number is represented.

If you are using a symbolic data type, meaning one that represents a number as a logical formula akin to program source code, and the operators on that data type work by manipulating tree expressions into other tree expressions, then you can easily represent an irrational number, and you can determine if a number is irrational, using mathematical proofs. Eg, programming languages like Wolfram Mathematica or their ilk probably work in exactly this fashion.

Otherwise, if you are using a non-symbolic data type like typical integer or floating-point data types, then even if they support arbitrarily large precision, they still can only represent rationals, and the test for irrational is easy, the answer is always "not irrational" for these types.

All the numeric types built into Raku are non-symbolic, so the test is simply "false".

There probably are or probably can be symbolic numeric types, but they wouldn't be core.

-- Darren Duncan

On 2020-02-19 6:57 p.m., ToddAndMargo via perl6-users wrote:
Hi All,

This is a complete trivia question.

Is there a test to see if a number is irrational,
such as the square root of two?

And how does Int handle a irrational number?  Is
there a limit to magic Larry powder?

Many thanks,
-T

Reply via email to