Am 28.10.2020 um 15:09 schrieb Ioannis Venetis:
d = abs(d)<0.00001 ? 0 : d
Hi,
as a related function let me point out that in the "extra" addon (that
is automatically shipped with gretl) we have zeroifclose() which is
aimed at matrix arguments, however. There the default but settable
threshold is 1e-12. Example:
<hansl>
include extra.gfn
matrix m = {1e-17, 1e-8}
zeroifclose(&m)
print m
</hansl>
Στις Τετ, 28 Οκτ 2020 στις 3:45 μ.μ., ο/η Artur Bala
<artur.bala.tn(a)gmail.com <mailto:artur.bala.tn@gmail.com>> έγραψε:
Hi,
Is it possible to "force" Gretl to show/compute simply a "0"
instead of a "1.1102e-16"?
For example, in the script below the d series holds, in theory,
nothing else but 0-s but in practice it still holds some kinds of
"1.1e-17" numbers
But a much more fundamental point is that this is simply the old thing
about floating-point arithmetic, where rounding and inexact
representation occurs. In most cases for the computer there is no real
difference between 1e-17 and 0. Therefore programming is best done a
little differently from what the algebraic formulas tell us. There is a
lot of classic literature about this.
cheers
sven