Home > atmlab > math > iswhole.m

iswhole

PURPOSE ^

ISWHOLE True for whole numbers (integers).

SYNOPSIS ^

function bool = iswhole(n)

DESCRIPTION ^

 ISWHOLE   True for whole numbers (integers).

    Determines if all the elements of an array are integers.

    Note that this function differs from *isinteger*, which is a type test. 
    Here also double numbers are accapted, as long they have no decimal part.

 FORMAT   bool = iswhole(n)
        
 OUT   bool   true if integer, else false.
 IN    n      A variable of any valid numeric data type.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

iswhole.m

SOURCE CODE ^

0001 % ISWHOLE   True for whole numbers (integers).
0002 %
0003 %    Determines if all the elements of an array are integers.
0004 %
0005 %    Note that this function differs from *isinteger*, which is a type test.
0006 %    Here also double numbers are accapted, as long they have no decimal part.
0007 %
0008 % FORMAT   bool = iswhole(n)
0009 %
0010 % OUT   bool   true if integer, else false.
0011 % IN    n      A variable of any valid numeric data type.
0012 
0013 % 2005-11-22  Renamed to avoid clash in newer Matlab versions (PE).
0014 % 2002-12-10  Adapted to Atmlab from arts/ami.
0015 % 2000-12-18  Created by Patrick Eriksson.
0016 
0017 
0018 function bool = iswhole(n)
0019 
0020 bool = isnumeric(n)  &&  all( n(:) - round(n(:)) == 0 );

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005