help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: testing for uint8: a solution


From: Bill Denney
Subject: Re: testing for uint8: a solution
Date: Sat, 4 Jun 2005 23:34:27 -0400 (EDT)

I found the following solution for testing whether a variable is uint8 (a question I had asked some time ago). Is there anything wrong with using this solution?

A simpler test is

octave:1> a = uint8(1)
a = 1
octave:2> class(a)
ans = uint8
octave:3> strcmpi(class(a), 'uint8')
ans = 1

int is_uint8(const octave_value &val) {

 if ((val.type_id() == octave_uint8_matrix::static_type_id()) ||
     (val.type_id () == octave_uint8_scalar::static_type_id())) {
   return(1);
 } else {
   return(0);
 }

}

Another thing to note, if you decide to keep this function, to be consistent, it should be "isuint8" instead of "is_uint8". (I don't know about the actual validity of the function though.)

Bill

--
Accept risk. Accept responsibility. Put a lawyer out of business.
  -- unknown



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]