Tcl 8.5
math::bigfloat version 2.0.1
The procedure math::bigfloat::isInt performs a very naive check to distinguish BigFloats from integers, but the check isn't nearly comprehensive enough to cover all or even most cases. The doc states that the proc should be able to distinguish standard Tcl 8.5 integers from other values. But note for example:
% isInt 2.0
1
% isInt 0.5
1
% isInt 1/2
1
% isInt [expr exp(1)]
1
% isInt i
1
% isInt HAM_SANDWICH
1
A better implementation might be something like:
proc isInt {n} {
if {[catch {set n [expr abs($n)]}]} {return 0}
if {[string first . $n] > -1} {return 0}
return 1
}
Here's a one-liner:
proc isInt {n} {expr ![catch {format %x $n}]}