The variable N1: = 1/12 gives the result: 0.08333(3)

When converting:

CN1: = STR (N1, 7, 3)

VN1: = VAL (CN1)

you rounded up to three decimal, which resulted in 0.083

In such a rounded number, multiplying by 12, we get the result: 0.996

Roberto Lopez wrote: ↑Mon Aug 13, 2018 11:41 pm

Code: Select all

```
N1 := 1/12 //=> 0.083333333
CN1 := STR( N1 ,7,3) //=> " 0.083"
VN1 := VAL( CN1 ) //=> 0.083
N2 := VN1 * 12 //=> 0.996
MSGINFO( STR( N2 ,7,3) ) //=> " 0.996"
```

See that:

Code: Select all

```
SET DECIMALS TO 3
N1 := 1/12
VN1 := VAL (STR( N1 ,7,3))
MSGDebug(N1, VN1, N1 == VN1)
```

Although SET DECIMALS TO 3 is set, the value of variable N1 is stored with the greatest precision. SET DECIMALS has no effect on the result of the calculation, only on its display.

Therefore, the value of N1== VN1 is returned as .F.

SET DECIMALS

Toggle the

**console display**
Syntax:

SET DECIMALS TO [<nDecimal>]

Arguments:

<nDecimal> Number of decimals places

Description:

This command establishes the number of decimal places that Harbour

**will display** in mathematical calculations, functions, memory variables, and fields.