Slightly related (but different) to this question: I needed frequently a
way to determine whether an integer is even or odd, and I finally wrote
this function:
<hansl>
function scalar iseven(scalar A)
if (A==floor(A))
scalar A2=floor(A/2)
scalar A2b=A/2
scalar even = (A2==A2b) ? 1 : 0
else
scalar even = NA
funcerr "Input is not an integer"
endif
return even
end function
# Examples:
scalar a=34
scalar b=iseven(a)
scalar c=67
scalar b=iseven(c)
b
scalar b=iseven($pi)
</hansl>
Do you think this maybe a candidate of being added to the list of gretl
native functions?
--
Ignacio Diaz-Emparanza
DEPARTAMENTO DE ECONOMÍA APLICADA III (ECONOMETRÍA Y ESTADÍSTICA)
UPV/EHU Avda. Lehendakari Aguirre, 83 | 48015 BILBAO
T.: +34 946013732 | F.: +34 946013754
www.ehu.es/ignacio.diaz-emparanza/
www.ea3.ehu.es