Hi, by the command of isinteger I can check if it is an integer, however, when defined at first, Matlab assume it is double precision right? So even a=3, isinteger(a) returns 0.
How to solve this problem?
No products are associated with this question.
Matlab represents integers in differnt ways:
I use this function to test for flint
function isf = isflint( m ) % floating double only try bitand( abs( m ), 1 ); isf = true; catch me isf = false; end end
I picked up the idea from a contribution by the "Pedestrian" in the FEX.
(I stripped off comments and error handling.)
Joining the rounding with the checks for overflows:
function isf = isflint(m) isf = (abs(m) <= bitmax && m == floor(m));
Play games and win prizes!Learn more