Re: [FlexJS]as int

2016-05-18 Thread Harbs
You’re right. My test was not done well. So it should probably be: >> return intVal === numVal ? intVal : null; On May 18, 2016, at 3:40 PM, Andy Dufilie wrote: > (5.3 as int) is null, and "var x:int = null;" becomes zero. > > Sent from my Android > On May 18, 2016 6:54 AM, "Harbs" wrote: >

Re: [FlexJS]as int

2016-05-18 Thread Andy Dufilie
(5.3 as int) is null, and "var x:int = null;" becomes zero. Sent from my Android On May 18, 2016 6:54 AM, "Harbs" wrote: > It seems like it’s 0. > > Either way, simply changing it to Number does not seem like a good > solution. > > We probably need to do something like this: > > function asInt(v

Re: [FlexJS]as int

2016-05-18 Thread Harbs
It seems like it’s 0. Either way, simply changing it to Number does not seem like a good solution. We probably need to do something like this: function asInt(value){ var intVal:int = int(value);//this should call parseInt() var numVal:Number = parseFloat(value) return intVal == numVal ? in

Re: [FlexJS]as int

2016-05-18 Thread Andy Dufilie
On May 18, 2016 2:50 AM, "Harbs" wrote: > > Isn’t this a behavior change? > > What happens if you do "5.3 as int” in ActionScript? Don’t you get 5? > I just tested this and got null.

Re: [FlexJS]as int

2016-05-17 Thread Harbs
Isn’t this a behavior change? What happens if you do "5.3 as int” in ActionScript? Don’t you get 5? On May 16, 2016, at 9:27 PM, Alex Harui wrote: > > > On 5/16/16, 9:47 AM, "Andy Dufilie" wrote: > >> There is no "int" type in JavaScript, so I think the compiler should just >> replace int w

Re: [FlexJS]as int

2016-05-17 Thread Harbs
Here’s the output of parseInt with different arguments: parseInt({foo:0},10));//NaN parseInt(10.7,10);10 parseInt("10.7",10);10 parseInt("7",10);//7 So, we should probably do something like: var val:Number = parseInt(value,10); return isNaN(val) ? 0 : val; What about uint? Something lik

Re: [FlexJS]as int

2016-05-17 Thread Alex Harui
It seems like we should continue to have the compiler call Language._int() and fix the implementation. Right now _int() just does this: static public function _int(value:Number):Number { return value >> 0; } Which I think is an attempt to truncate the Number. D

Re: [FlexJS]as int

2016-05-17 Thread Josh Tynjala
If you use 10 as the radix, you're fine. The strange behavior is when you omit the radix because some browsers try to be smart and detect things like a leading 0 as an octal number. - Josh On Tue, May 17, 2016 at 12:17 AM, Tom Chiverton wrote: > I think parseInt() in JS has really odd behaviour

Re: [FlexJS]as int

2016-05-17 Thread Harbs
As long as you use radix, I know of no issues. How does ">> 0” work? I don’t think I’ve come across that before. On May 17, 2016, at 10:17 AM, Tom Chiverton wrote: > I think parseInt() in JS has really odd behaviour and is best avoided. > > Tom > > On 17 May 2016 07:46:07 BST, Alex Harui wr

Re: [FlexJS]as int

2016-05-17 Thread Tom Chiverton
I think parseInt() in JS has really odd behaviour and is best avoided. Tom On 17 May 2016 07:46:07 BST, Alex Harui wrote: >I pushed changes for just the "x as int" case. > >On 5/16/16, 12:30 PM, "Harbs" wrote: > >>I assume int() will cross-compile to parseInt()? > >Currently the compiler calls

Re: [FlexJS]as int

2016-05-16 Thread Alex Harui
I pushed changes for just the "x as int" case. On 5/16/16, 12:30 PM, "Harbs" wrote: >I assume int() will cross-compile to parseInt()? Currently the compiler calls Language._int(), but the code in there doesn't call parseInt. Should it? -Alex

Re: [FlexJS]as int

2016-05-16 Thread Harbs
I assume int() will cross-compile to parseInt()? On May 16, 2016, at 9:27 PM, Alex Harui wrote: > > > On 5/16/16, 9:47 AM, "Andy Dufilie" wrote: > >> There is no "int" type in JavaScript, so I think the compiler should just >> replace int with Number. > > I agree. I will look into it. > >

Re: [FlexJS]as int

2016-05-16 Thread Alex Harui
On 5/16/16, 9:47 AM, "Andy Dufilie" wrote: >There is no "int" type in JavaScript, so I think the compiler should just >replace int with Number. I agree. I will look into it. -Alex

Re: [FlexJS]as int

2016-05-16 Thread Andy Dufilie
There is no "int" type in JavaScript, so I think the compiler should just replace int with Number. In general I would not recommend using "as Number" or "as int" anyway, since it returns null if the value is of a different type, and null cast to Number or int becomes zero rather than NaN. On Mon,

[FlexJS]as int

2016-05-16 Thread Harbs
The new sortOn code is causing a compile error in Language.as: Language.js:408: WARNING - variable int is undeclared [java] opt2 = org.apache.flex.utils.Language.as(opt, int); I can easily fix this by changing opt2 = opt as int; to opt2 = int(opt); but I think this is a bug in the “as” i