>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  Help  Primer

Inexact numbers

The way numbers are stored in a computer limits the maximum number of digits in the number. This maximum depends on the hardware, but typically a pps argument of 20 guarantees that all the digits available for a value will be displayed.
   pps 6
   pps 12
   pps 20
At 20 digits of precision the result of %3 displays all the detail it has on the number in 17 digits. The result of %3 is not the exact mathematical result, but is the closest number to that exact result that can be stored in the computer. This difference between what you would expect from exact math and the limitations on how numbers are stored in computers can be confusing.
   3 * % 3
The result of %3 is not the exact value, but it is so close that when multiplied by 3 it gives the exact expected value of 1.
   3 * 10 * % 3
Multiplying the inexact result of %3 by 10 magnifies the error, but it is still close enough to the exact value that when multiplied by 3 it gives the exact expected value of 10.
   3 * 100 * % 3
However, multiplying %3 by 100 magnifies the error enough so that when multiplied by 3 you do not get the exact expected answer of 100, but instead get a number that is very close to 100.

Using lists you can combine the above examples.
   3 * 1 10 100 * % 3
1 10 99.999999999999986
The fact the %3 isn't stored exactly in the computer may not surprise you too much if you realize that an exact representation in decimal digits would take an infinite numbers of 3's.

There is an additional source of confusion due to the fact that computers store numbers internally in a binary format where each digit is a 0 or 1, rather than the decimal format you are familiar with where the digits range in value from 0 to 9. A consequence of this is that even very simple decimal numbers, exactly expressed with a few digits, when converted to the computer's binary format, are stored as an inexact value.
   pps 20
   0.5 0.25 0.1
0.5 0.25 0.10000000000000001
The 0.5 and 0.25 are stored exactly, but the 0.1 is stored inexactly, and when displayed with maximum precision shows as 0.10000000000000001 .

These are facts of life with the way computers store floating point numbers and apply to all computer languages, not just J. Usually you can ignore these details, but they can sometimes cause problems or confusion if you don't have an idea about what is going on.

>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  Help  Primer