Thank you Ioannis and Sven!!!
To be frank, the kind of expression "abs(d)<0.00001 ? 0 : d" sounds to me
not that much intuitive - anyway, less than zeroifclose() stuff - but
probably it's just lack of experience.
Best,
Artur
Le mer. 28 oct. 2020 à 15:54, Sven Schreiber <svetosch(a)gmx.net> a écrit :
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> έγραψε:
> 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
_______________________________________________
Gretl-users mailing list -- gretl-users(a)gretlml.univpm.it
To unsubscribe send an email to gretl-users-leave(a)gretlml.univpm.it
Website:
https://gretlml.univpm.it/postorius/lists/gretl-users.gretlml.univpm.it/