function nonintegerp (was RE: should all floats be nonintegers?)



Final comments?

;; Return true if, by fairly simple methods, Maxima is able to determine that the input (i) represents a complex
;; number,(ii) is not a floating point number, and (iii) isn't an integer. In all other cases, return false.

;; not done: (1) rational x irrational (2) nonzero even / nonzero odd (3)  ... Also, the function
;; check-noninteger-fact apparently checks the fact database to one ply:
;;   (assume(equal(a,b), equal(b,c)), declare(c,noninteger), featurep(a,noninteger)) --> false

(defun nonintegerp (e)
  (cond ((complex-number-p e #'mnump)
     (if (integerp e) nil t))
    ((symbolp e)
     (or (kindp e '$noninteger) (check-noninteger-facts e) (kindp e '$irrational))) ;declared noninteger
    (($ratp e) (nonintegerp ($ratdisrep e)))
    ((memq e '($minf $inf $infinity $zerob $zeroa $und $ind)) nil)
    ((or (mbagp e) ($setp e) (arrayp e)) nil) ;what else?
    (t (eq t (mgrp e (take '($floor) e))))))

Tests--appended to rtest6b.mac:

map(lambda([s],featurep(s,noninteger)), [%pi,%phi,%gamma, %pi/8,sqrt(5),3/8,-5/7]);
[true,true,true,true,true,true,true]$

map(lambda([s],featurep(s,noninteger)), [minf,inf,und,ind,infinity,true,false,-1,0,1]);
[false,false,false,false,false,false,false,false,false,false]$

map(lambda([s],featurep(s,noninteger)), [0.0, -1.0, 0.0b0,42.0b0, 4+%i, 4.5-%i, 5.2b0+1.2*%i]);
[true, true, true, true, true, true, true]$


--Barton

________________________________