Well, it turns out that doesn't work either if the int is positive. If
an int is positive all of the follow tests return true:

var testInt:int = 5;
var obj:Object = testInt;

obj is int -> true
obj is uint -> true
obj is Number -> true

Sooooo, I'm back to assuming there is no way to tell an int from a uint.
 

--- In [email protected], "Paul Whitelock" <[EMAIL PROTECTED]> wrote:
>
> I found another way that seems to work (not sure why though):
> 
> var testUint:uint = 1;
> var testInt:int = -1;
> var testNumber:Number = 1.1;
> 
> var obj:Object = testUint;
> 
> trace ("uint: " + (obj is uint && obj is int));
> trace ("int: " + (obj is int && !(obj is uint)));
> trace ("Number: " + ((obj is Number) && !(obj is int) && !(obj is
uint)));
> 
> Output:
> uint: true
> int: false
> Number: false
> 
> obj = testInt;
> 
> trace ("uint: " + (obj is uint && obj is int));
> trace ("int: " + (obj is int && !(obj is uint)));
> trace ("Number: " + ((obj is Number) && !(obj is int) && !(obj is
uint)));
> 
> Output:
> 
> uint: false
> int: true
> Number: false
> 
> obj = testNumber;
> 
> trace ("uint: " + (obj is uint && obj is int));
> trace ("int: " + (obj is int && !(obj is uint)));
> trace ("Number: " + ((obj is Number) && !(obj is int) && !(obj is
uint)));
> 
> Output:
> uint: false
> int: false
> Number: true
> 
> 
> --- In [email protected], "Paul Whitelock" <paul@> wrote:
> >
> > Thanks! That did help, but it doesn't seem to work for a uint. Here's
> > my test code:
> > 
> > var testUint:uint = 1;
> > var testInt:int = -1;
> > var testNumber:Number = 1.1;
> > var testString:String = "test";
> > var testDate:Date = new Date();
> > var testArray:Array = new Array();
> >                             
> > var test:Array = [testUint, testInt, testNumber, testString, testDate,
> > testArray];
> >                 
> > for (var i:uint = 0; i < test.length; i++) {
> >     var typeInfo:String = describeType(test[i])[EMAIL PROTECTED]();
> >     trace(typeInfo);
> > }
> > 
> > And here's the output:
> > 
> > int
> > int
> > Number
> > String
> > Date
> > Array
> > 
> > I'm guessing there's no way to identify a uint -- is that correct?
> > 
> > 
> > --- In [email protected], "Alex Harui" <aharui@> wrote:
> > >
> > > There is code that might help in
> > > DataGrid.as:itemEditorItemEditEndHandler
> > > 
> > > ________________________________
> > > 
> > > From: [email protected]
> [mailto:[EMAIL PROTECTED] On
> > > Behalf Of Paul Whitelock
> > > Sent: Thursday, May 15, 2008 12:31 PM
> > > To: [email protected]
> > > Subject: [flexcoders] How to tell if variable is an int, uint, or a
> > > Number?
> > > 
> > >  
> > > 
> > > I have a situation where an untyped variable is passed in a method
> > > call and I need to determine the data type for the variable. My
first
> > > thought was to use typeof, but typeof returns "number" for an int,
> > > uint, or a Number. The operator "is" will not work on primitives.
> > > 
> > > Is there any way to determine the data type of an untyped primitive
> > > object?
> > >
> >
>


Reply via email to