This section is a bit advanced and understanding it is not critical. If it makes sense, great. If not, don't worry about it, and just move on to the next section.
For some kinds of work with floating point numbers, this section is important, along with a more detailed understanding of how numbers are stored and manipulated by the hardware. For most work, however, this section can be ignored.
At the end of the last section we saw that computer cannot always represent numbers exactly. So how do we know if a number is equal to another number if they can't be exactly represented? the solution to this is the concept of tolerant comparison. That is, numbers do not have to be exactly identical to be considered equal.
Let's experiment to get an idea for how tolerant the comparison is by gradually taking the value further away from 100. The input line recall shortcut with Shift+Ctrl+up arrow is very useful for playing with things like this.
100 = 100 1 100 = 99.999999999999986 1 100 = 99.99999999999998 1 100 = 99.9999999999999 1 100 = 99.999999999999 1 100 = 99.99999999999 0
In the last example you crossed the line and the value is far enough away from 100 that it is no longer considered to be equal. Let's look at another example.
a =. 23 b =. a - 1e_12 c =. a - 1e_11 a 23 a-b 9.9831254374294076115e_13 a=b 1 a-c 1.0000889005823410116e_11 a=c 0
The values of a and b are close enough to be considered equal. The values of a and c are not close enough to be considered equal. Close enough refers to the difference between the two numbers. In both cases the difference is small, but b is closer than c to a. Reading the NuVoc definition for = you will see that the dividing line between close enough and not close enough is determined by the result of multiplying the larger of the numbers times the default tolerance value of 2^_44. That is, close enough is relative to the size of the numbers.
tolerance =. a * 2 ^ _44 tolerance 1.307398633798584342e_12
Check both differences against this tolerance:
(a - b , c) <: tolerance NB. Remember, this is equivalent to (a - (b,c)) due to right to left precedence. 1 0
|Primer Index Hover to reveal titles - Click to access -|