There may be a world where a language can do identity / symbol math - indeed there are cpan packages for this kind of thing. But core Raku does not attempt to do that.
Raku is (fortunately) pretty simplistic: you get Ints, Rats and Nums (well and Complex but that's another topic). This aligns to mathematics number spaces Integers, Rational and Irrational numbers. Some operations (eg. sqrt(2)) will make an irrational number. Without symbolic math, you lose a little precision in any machine with finite word size and cannot fully restore the initial state with a round trip. Rounding can hide this.
> my $t=sqrt(2)
1.4142135623730951
> $t ** 2
2.0000000000000004
sooooo
You are plumbing the edges of IEEE754 here ... and very small numbers are subject to all kinds of influences ... here is a good write up ...https://randomascii.wordpress.com/2013/07/16/floating-point-determinism/
Back in the day many FPUs did random seed guess for division/sqrt ... even if that practice has become standardised to make the result deterministic (every pass is the same), it certainly will not require each FPU design to guess the same seed.
And this ignores the fact that FPU designers will often shortcut full IEEE754 to save on transistors, various compiler settings.
Not to rule out frequent chip logic design errors that do not get caught since the test sw will judge any of the near '0' as zero.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|