On 2020-02-20 05:53, Richard Hainsworth wrote:
However, my question to you is: when would you come across an irrational number in a computer? How would you express it? Suppose I gave you a function sub irrational( $x ) which returns true for an irrational number. What would you put in for $x? Bear in mind that anything like pi or sqrt(2) is either going to be infinitely long or a rational approximation.
Hi Richard, The question was meant as trivia. Raku never ceased to amaze me in its capabilities, so I though it had come up with some elegant/impressive way (also known as Magic Larry Powder) of handling it. And yes, UInt and Int do fall into that category with me. On the practical side, I am an engineer and what I am interested is the "tolerance" of a number. For example, 1.0 and 1.000 are not the same number. The first one is 1.0 ± 0.05 and the second one is 1.000 ± 0.0005. And when doing math on such numbers, the tolerance of the result always takes on the worst tolerance of the numbers being manipulated. So it is the square root of two taken to the length of the tolerance of the other variables. So rational or irrational has no practical meaning to me. And why the rounding in Raku is so adored. Oh and if I wanted to run the trivia up the flag pole, I'd remark on the difference between common rounding and scientific rounding. Scientific routing is actually the correct way, as it is balanced, but few understand what it is so using common rounding keeps you on their good side. -T