RE: [flexcoders] Simple arithmetic - resolved

2005-04-19 Thread Gordon Smith

Math operations with normal numbers, such as 0/0 and Math.sqrt(-1), can also
produce NaN. 

According to the ECMA-262 spec, NaN is a Number, despite its name meaning
"Not a Number":

"4.3.20 Number Type
The type Number is a set of values representing numbers. In ECMAScript, the
set of values represents the double-precision 64-bit format IEEE 754 values
including the special "Not-a-Number" (NaN) values, positive infinity, and
negative infinity."

The concept of NaN dates back at least to the IEEE 754 specification for
binary floating-point arithmetic.

- Gordon


-Original Message-
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 19, 2005 4:09 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Simple arithmetic - resolved



> Question - shouldn't this have thrown an error, since I was casting
the
> non-number variable as a number in the parameter statement, as 
> varX:Number?

Flash is not checking types runtime, only compile time. And compile time
everything is programmed right

>trace(!isNaN(NaN));

NaN is kind of its own type and is usually the result of an equation
with a string or some other non-numeric type.


Greetz Erik


-Original Message-
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of JesterXL
Sent: maandag 18 april 2005 21:53
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Simple arithmetic - resolved


A number is not a number?  wtf, lol!

trace(!isNaN(NaN)); // false

...crud, that means it is... but how can a number that's not a number be
a number?

I'm confused now...



 
Yahoo! Groups Links



 





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 





RE: [flexcoders] Simple arithmetic - resolved

2005-04-19 Thread Erik Westra

> Question - shouldn't this have thrown an error, since I was casting
the
> non-number variable as a number in the parameter statement, as 
> varX:Number?

Flash is not checking types runtime, only compile time. And compile time
everything is programmed right

>trace(!isNaN(NaN));

NaN is kind of its own type and is usually the result of an equation
with a string or some other non-numeric type.


Greetz Erik


-Original Message-
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of JesterXL
Sent: maandag 18 april 2005 21:53
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Simple arithmetic - resolved


A number is not a number?  wtf, lol!

trace(!isNaN(NaN)); // false

...crud, that means it is... but how can a number that's not a number be
a number?

I'm confused now...



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 





Re: [flexcoders] Simple arithmetic - resolved

2005-04-18 Thread Manish Jethani

On 4/19/05, JesterXL <[EMAIL PROTECTED]> wrote:

> A number is not a number?  wtf, lol!
> 
> trace(!isNaN(NaN)); // false
> 
> ...crud, that means it is... but how can a number that's not a number be a
> number?

Okay, I'll avoid getting into any language discussion by saying that I
really meant that NaN can be safely assigned to a Number reference
without a cast.

  var x:Number = NaN;

That may or may not mean that NaN is a Number.  Pick up a Colin Moock
book if you care to find out (I don't).  It can be said that NaN is to
Number as null is to Object (but I won't say it, because I already
did).

-- 
[EMAIL PROTECTED]
http://manish.revise.org/


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 





Re: [flexcoders] Simple arithmetic - resolved

2005-04-18 Thread JesterXL

A number is not a number?  wtf, lol!

trace(!isNaN(NaN)); // false

...crud, that means it is... but how can a number that's not a number be a 
number?

I'm confused now...

- Original Message - 
From: "Manish Jethani" <[EMAIL PROTECTED]>
To: 
Sent: Monday, April 18, 2005 3:48 PM
Subject: Re: [flexcoders] Simple arithmetic - resolved



On 4/18/05, Tom Fitzpatrick <[EMAIL PROTECTED]> wrote:

> Solved - turns out I was applying a currency format to the variable before
> handing it to the function so it really was NaN.
>
> Question - shouldn't this have thrown an error, since I was casting the
> non-number variable as a number in the parameter statement, as 
> varX:Number?

NaN is of type Number, AFAIK.

-- 
[EMAIL PROTECTED]
http://manish.revise.org/



Yahoo! Groups Links








 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 





Re: [flexcoders] Simple arithmetic - resolved

2005-04-18 Thread Manish Jethani

On 4/18/05, Tom Fitzpatrick <[EMAIL PROTECTED]> wrote:

> Solved - turns out I was applying a currency format to the variable before
> handing it to the function so it really was NaN.
> 
> Question - shouldn't this have thrown an error, since I was casting the
> non-number variable as a number in the parameter statement, as varX:Number?

NaN is of type Number, AFAIK.

-- 
[EMAIL PROTECTED]
http://manish.revise.org/


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 





Re: [flexcoders] Simple arithmetic - resolved

2005-04-18 Thread Tom Fitzpatrick

Solved - turns out I was applying a currency format to the variable before 
handing it to the function so it really was NaN.

Question - shouldn't this have thrown an error, since I was casting the 
non-number variable as a number in the parameter statement, as varX:Number?

- Tom

At 04:43 PM 4/17/2005, you wrote:
>Manish and Abdul - Thanks. I'll keep looking...
>
>- Tom
>
>At 03:53 PM 4/17/2005, you wrote:
> >I verified that the function returns correct values.  You have a
> >problem somewhere else.
>
>
>
>
>
>
>--
>Yahoo! Groups Links
>* To visit your group on the web, go to:
>* 
> http://groups.yahoo.com/group/flexcoders/
>  
>
>*
>* To unsubscribe from this group, send an email to:
>* 
> [EMAIL PROTECTED] 
>
>*
>* Your use of Yahoo! Groups is subject to the 
> Yahoo! Terms of Service.






 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 





Re: [flexcoders] Simple arithmetic

2005-04-17 Thread Tom Fitzpatrick

Manish and Abdul - Thanks. I'll keep looking...

- Tom

At 03:53 PM 4/17/2005, you wrote:
>I verified that the function returns correct values.  You have a
>problem somewhere else.






 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 





Re: [flexcoders] Simple arithmetic

2005-04-17 Thread Manish Jethani

On 4/17/05, Tom Fitzpatrick <[EMAIL PROTECTED]> wrote:

> function getPercentages(varX:Number,varY:Number,varZ:Number)
> {

[snip]

> Feeding the numbers
> 
> varX = 80
> varY = 20
> varZ = 100,000
> 
> should yield this list:
> 
> Salary: $80,000
> Bonus: $20,000

I verified that the function returns correct values.  You have a
problem somewhere else.

-- 
[EMAIL PROTECTED]
http://manish.revise.org/


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 





RE: [flexcoders] Simple arithmetic

2005-04-17 Thread Tom Fitzpatrick

OK - here's more info.

I'm passing the returned array as the dataprovider for a list (passed as 
"dataObject"):



The labelFunction is:

 function myLabelFunction(item):String
 {
 return item.label + ": " + item.data;
 }

Does that help?

I thought the string conversion in the function would do the trick, because 
the labelFunction is looking for strings, but that still gives me a NaN.

- Tom

At 10:11 AM 4/17/2005, you wrote:
>Hi,
>
>Everything in function seems to be right, I feel something is wrong
>somewhere else.
>
>Can you post the code, how you are calling this function.
>
>To isolate the problem, just call this function and show results in alert.
>
>e.g.
>
>alert(getPercentages(80,20,1)[0].data)
>
>
>-abdul
>
>
>-Original Message-
>From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED]
>Sent: Sunday, April 17, 2005 5:40 PM
>To: flexcoders@yahoogroups.com
>Subject: [flexcoders] Simple arithmetic
>
>
>I'm trying to pass three numbers to a function and have it return an array
>containing two numbers that will be used as the dataprovider for a list.
>The list uses a labelFunction to display items in the form:
>
>"label": "data"
>"label": "data"
>
>for example:
>
>Salary: $80,000
>Bonus: $20,000
>
>Here's the latest thing I tried (doesn't work, but shows what I'm shooting
>for):
>
>function getPercentages(varX:Number,varY:Number,varZ:Number)
>{
> varX= (varX/100)*varZ;
> varY= (varY/100)*varZ;
> var newSalary = varX.toString();
> var newBonus = varY.toString();
> var newFigures = [
> {label:"Salary",data:newSalary},
> {label:"Bonus",data:newBonus}
> ];
> return newFigures;
>}
>
>Feeding the numbers
>
>varX = 80
>varY = 20
>varZ = 100,000
>
>should yield this list:
>
>Salary: $80,000
>Bonus: $20,000
>
>Instead, I get:
>
>Salary: NaN
>Bonus: NaN
>
>Assuming I've provided enough information, can anyone see what's wrong?
>
>- Tom
>
>
>
>
>
>
>
>Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>--
>Yahoo! Groups Links
>* To visit your group on the web, go to:
>* 
> <http://groups.yahoo.com/group/flexcoders/>http://groups.yahoo.com/group/flexcoders/
>  
>
>*
>* To unsubscribe from this group, send an email to:
>* 
> <mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED] 
>
>*
>* Your use of Yahoo! Groups is subject to the 
> <http://docs.yahoo.com/info/terms/>Yahoo! Terms of Service.






 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 





RE: [flexcoders] Simple arithmetic

2005-04-17 Thread Abdul Qabiz

Hi,

Everything in function seems to be right, I feel something is wrong
somewhere else.

Can you post the code, how you are calling this function.

To isolate the problem, just call this function and show results in alert.

e.g.

alert(getPercentages(80,20,1)[0].data)


-abdul
 

-Original Message-
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] 
Sent: Sunday, April 17, 2005 5:40 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Simple arithmetic


I'm trying to pass three numbers to a function and have it return an array 
containing two numbers that will be used as the dataprovider for a list. 
The list uses a labelFunction to display items in the form:

"label": "data"
"label": "data"

for example:

Salary: $80,000
Bonus: $20,000

Here's the latest thing I tried (doesn't work, but shows what I'm shooting 
for):

function getPercentages(varX:Number,varY:Number,varZ:Number)
{
varX= (varX/100)*varZ;
varY= (varY/100)*varZ;
var newSalary = varX.toString();
var newBonus = varY.toString();
var newFigures = [
{label:"Salary",data:newSalary},
{label:"Bonus",data:newBonus}
];
return newFigures;
}

Feeding the numbers

varX = 80
varY = 20
varZ = 100,000

should yield this list:

Salary: $80,000
Bonus: $20,000

Instead, I get:

Salary: NaN
Bonus: NaN

Assuming I've provided enough information, can anyone see what's wrong?

- Tom






 
Yahoo! Groups Links



 





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 





[flexcoders] Simple arithmetic

2005-04-17 Thread Tom Fitzpatrick

I'm trying to pass three numbers to a function and have it return an array 
containing two numbers that will be used as the dataprovider for a list. 
The list uses a labelFunction to display items in the form:

"label": "data"
"label": "data"

for example:

Salary: $80,000
Bonus: $20,000

Here's the latest thing I tried (doesn't work, but shows what I'm shooting 
for):

function getPercentages(varX:Number,varY:Number,varZ:Number)
{
varX= (varX/100)*varZ;
varY= (varY/100)*varZ;
var newSalary = varX.toString();
var newBonus = varY.toString();
var newFigures = [
{label:"Salary",data:newSalary},
{label:"Bonus",data:newBonus}
];
return newFigures;
}

Feeding the numbers

varX = 80
varY = 20
varZ = 100,000

should yield this list:

Salary: $80,000
Bonus: $20,000

Instead, I get:

Salary: NaN
Bonus: NaN

Assuming I've provided enough information, can anyone see what's wrong?

- Tom






 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/