# 1. Scilab precision

## 1.1. Linux 32 bits

Like many other software, Scilab 4.X was working with extended precision floats. This could lead to bugs on very specific computations. This issue is well described on this page. For example, the following code:

x = 9007199254740994.0; y = 1.0 - 1/65536.0; z = x + y; z-x

will return 2.0 in Scilab extended precision and 0.0 in double precision. (for example, Python has the same issue). The exact result is x+y-x = y = 1.0 - 1/65536.0 so that both extended precision and double precision results are *approximations*. The reason why 0.0 is to prefer is that it is a *reproductible* result, i.e. it is the same result that we get on Linux, Windows, 32 bits or 64 bits, when we use double precision.

The "funny" fact is that the extended precision result is not better, even if the extended precision uses 64 bits for the mantissa (instead of the 53 bits of the double precision mantissa).

Scilab 5.X is now working in double precision. Therefore, the precision is improved (i.e. is made consistent with the result we get on other platforms with the same precision) on some specific computation like the one described.

### 1.1.1. Technical aspect

The change of the precision is done in the file *modules/core/src/c/setPrecisionFPU.c* function *setFPUToDouble*:

fpu_control_t _cw; _FPU_GETCW(_cw); _cw = (_cw & ~_FPU_EXTENDED) | _FPU_DOUBLE; _FPU_SETCW(_cw);

which is called in the file *modules/shell/src/c/others/mainscic.c*

Since Scicos is using the function pow in the case of the bug, we reset the precision to extended in the file *modules/scicos/src/c/scicos.c*:

setFPUToExtended();

## 1.2. Linux 64 bits

Scilab under Linux 64 bits is not touched by this issue.

## 1.3. Windows & others

Scilab is working with double precision floats. These kind of problems do not occur.

# 2. Misc