Question about integer?, float? and number?
Posted: Sat Jan 13, 2007 10:48 pm
Lutz,
NewLISP currently allows direct numerical input in number bases 8, 10 and 16 with the 0 and 0x prefixes for the binary bases. The integer?, float? and number? functions all return true if you input an octal or hexadecimal base number into them. I ran into a situation where I needed one or more of these functions to return true only for decimal representations. Could we have an extra argument on these functions where the user could specify one or more bases that they wish the function to test for? If no base is specified then all bases are tested for otherwise only the bases listed will be tested. For example:
(integer? n) - all bases tested for
(integer? n 8) - only base 8 integers acceptable
(integer? n '(10 16)) - decimal and hexadecimal acceptable
NewLISP currently allows direct numerical input in number bases 8, 10 and 16 with the 0 and 0x prefixes for the binary bases. The integer?, float? and number? functions all return true if you input an octal or hexadecimal base number into them. I ran into a situation where I needed one or more of these functions to return true only for decimal representations. Could we have an extra argument on these functions where the user could specify one or more bases that they wish the function to test for? If no base is specified then all bases are tested for otherwise only the bases listed will be tested. For example:
(integer? n) - all bases tested for
(integer? n 8) - only base 8 integers acceptable
(integer? n '(10 16)) - decimal and hexadecimal acceptable