RE: [flexcoders] Re: Number(011) = 9 ????

2005-10-05 Thread Abdul Qabiz
Hi,

I think, you need to write a function to remove 0 from string and cast the rest 
of string as Number.

So probably, a private helper-method in your class can do thisBut in 
ActionScript, any number with 0 as prefix would be considered as an octal..


function getDecimalNumber(numStr:String):Number
{
if(numStr.indexOf(0)== 0)
{
return Number(numStr.substr(1));
}

return Number(numStr);
}


-abdul 

-Original Message-
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of 
Christoph Diefenthal
Sent: Wednesday, October 05, 2005 12:51 PM
To: 'flexcoders@yahoogroups.com'
Subject: AW: [flexcoders] Re: Number(011) = 9 

Well sorry, I haven't been specific enough.

Here it comes:
I have got Strings of the form 009, 010, 011,..., 999 which I expect
to be a decimal number, and so I was confused, that the output of
Number(011) is 9. 

I didn't know that a 0 in front of literal is a specifier for octal
literals.

So parseInt(011,10) does exactly what I want to do. It interprets 011 as
the decimal 11.

My last question was only, whether there is a way to use the Number class to
produce this output, because I thought that it is not the most
object-oriented way to use the global function parseInt(...)...

Thanks for the replies 
Christoph






 -Ursprüngliche Nachricht-
 Von: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] Im
 Auftrag von Gordon Smith
 Gesendet: Dienstag, 4. Oktober 2005 20:05
 An: flexcoders@yahoogroups.com
 Betreff: RE: [flexcoders] Re: Number(011) = 9 
 
 If you do parseInt(011, 10), I'm pretty sure what happens is this:
 
 1. The octal literal 011 is compiled as the decimal Number 9.
 2. It is converted at runtime to the string 9, because parseInt expects
 to parse a string.
 3. parseInt parses 9 to produce 9.
 
 Obviously, this is a waste of time. 011 already *is* 9 at compile time. It
 is just a different way of writing it, just like 0x09 is a different way
 of writing it. For example, try this:
 
 trace(011 - 1);
 
 The output is 8.
 
 - Gordon
 
 
 -Original Message-
 From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
 Behalf Of Abdul Qabiz
 Sent: Tuesday, October 04, 2005 10:29 AM
 To: flexcoders@yahoogroups.com
 Subject: RE: [flexcoders] Re: Number(011) = 9 
 
 Hi,
 
 What do you want to do?
 
 Convert 011 to decimal 11
 
 Or convert octal(11) to decimal(9)
 
 parseInt(..) is a global function and first argument is an expression, so
 you can pass number also:
 
 parseInt(011, 10) - 9 (decimal)
 
 You can look at Flash Player ActionScript on:
 
 http://livedocs.macromedia.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/js/htm
 l/wwhelp.htm?href=Part_ASLR.html
 
 
 -abdul
 
 
 -Original Message-
 From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
 Behalf Of Christoph Diefenthal
 Sent: Tuesday, October 04, 2005 7:34 PM
 To: 'flexcoders@yahoogroups.com'
 Subject: AW: [flexcoders] Re: Number(011) = 9 
 
 Ok thank you all,
 
 I workaround (or isn't it a workaround??) this problem by using
 parseInt(011, 10) to get the decimal-system value.
 
 How can I use the Number-class to convert the values?
 Is there a
 Number.parseInt() function?
 
 There is no such function mentioned in the Flex ActionScript Language
 Reference... can you provide me with a better API?
 
 
 Cheers
 Christoph
 
 
 
  -Ursprüngliche Nachricht-
  Von: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] Im
  Auftrag von Philippe Maegerman
  Gesendet: Dienstag, 4. Oktober 2005 12:24
  An: flexcoders@yahoogroups.com
  Betreff: RE: [flexcoders] Re: Number(011) = 9 
 
  If they are all octal numbers, you can use
  mx.controls.Alert.show( + Number(011).toString(8));
 
  Philippe Maegerman
 
  
 
  From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
  Behalf Of jamiebadman
  Sent: mardi 4 octobre 2005 11:34
  To: flexcoders@yahoogroups.com
  Subject: [flexcoders] Re: Number(011) = 9 
 
 
  It's performing an octal to decimal conversion. You can use the
  Number class to convert between various different number bases.
 
  Jamie.
 
  --- In flexcoders@yahoogroups.com, Christoph Diefenthal
  [EMAIL PROTECTED] wrote:
   Does anyone know why this happens???
  
   Try it on your own server  :
  
  
  
 mx:Application
  xmlns:mx=http://www.macromedia.com/2003/mxml;
   mx:Button label=Value Of String click=valueOfString
  () /
   mx:Script
 ![CDATA[
 import mx.controls.Button;
  
 public function valueOfString():Void
 {
  
   // the result is 9 ?
  mx.controls.Alert.show( + Number(011));
  
 }
 ]]
   /mx:Script
 /mx:Application
 
 
 
 
  --
  Flexcoders Mailing List
  FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
  Search Archives: http://www.mail-
 archive.com/flexcoders

RE: [flexcoders] Re: Number(011) = 9 ????

2005-10-05 Thread Philippe Maegerman





Maybe try to pass the value as a String instead of a 
Number and eventualy remove the leading '0' in the String beforecasting it 
as a Number

Philippe 
Maegerman



From: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] On Behalf Of Christoph 
DiefenthalSent: mercredi 5 octobre 2005 9:21To: 
'flexcoders@yahoogroups.com'Subject: AW: [flexcoders] Re: 
Number("011") = 9 
Well sorry, I haven't been specific enough.Here it 
comes:I have got Strings of the form "009", "010", "011",..., "999" which I 
expectto be a decimal number, and so I was confused, that the output 
ofNumber("011") is 9. I didn't know that a 0 in front of literal is 
a specifier for octalliterals.So parseInt("011",10) does exactly 
what I want to do. It interprets "011" asthe decimal 11.My last 
question was only, whether there is a way to use the Number class toproduce 
this output, because I thought that it is not the mostobject-oriented way to 
use the global function parseInt(...)...Thanks for the replies 
Christoph -Ursprüngliche 
Nachricht- Von: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] Im Auftrag von Gordon Smith 
Gesendet: Dienstag, 4. Oktober 2005 20:05 An: 
flexcoders@yahoogroups.com Betreff: RE: [flexcoders] Re: Number("011") = 
9   If you do parseInt(011, 10), I'm pretty sure what 
happens is this:  1. The octal literal 011 is compiled as the 
decimal Number 9. 2. It is converted at runtime to the string "9", 
because parseInt expects to parse a string. 3. parseInt parses 
"9" to produce 9.  Obviously, this is a waste of time. 011 
already *is* 9 at compile time. It is just a different way of writing 
it, just like 0x09 is a different way of writing it. For example, try 
this:  trace(011 - 1);  The output is 8. 
 - Gordon   -Original Message- 
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On 
Behalf Of Abdul Qabiz Sent: Tuesday, October 04, 2005 10:29 AM 
To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Re: 
Number("011") = 9   Hi,  What do you want to 
do?  Convert 011 to decimal 11  Or convert 
octal(11) to decimal(9)  parseInt(..) is a global function and 
first argument is an _expression_, so you can pass number also: 
 parseInt(011, 10) - 9 (decimal)  You can look at 
Flash Player ActionScript on:  http://livedocs.macromedia.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/js/htm 
l/wwhelp.htm?href="">   -abdul 
  -Original Message- From: 
flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf 
Of Christoph Diefenthal Sent: Tuesday, October 04, 2005 7:34 PM 
To: 'flexcoders@yahoogroups.com' Subject: AW: [flexcoders] Re: 
Number("011") = 9   Ok thank you all,  I 
workaround (or isn't it a workaround??) this problem by using 
parseInt("011", 10) to get the decimal-system value.  How can I 
use the Number-class to convert the values? Is there a 
Number.parseInt() function?  There is no such function mentioned 
in the "Flex ActionScript Language Reference... can you provide me with 
a better API?   Cheers Christoph 
-Ursprüngliche Nachricht-  
Von: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] Im 
 Auftrag von Philippe Maegerman  Gesendet: Dienstag, 4. Oktober 
2005 12:24  An: flexcoders@yahoogroups.com  Betreff: RE: 
[flexcoders] Re: Number("011") = 9    If they are 
all octal numbers, you can use  mx.controls.Alert.show("" + 
Number("011").toString(8));   Philippe Maegerman 
     
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On 
 Behalf Of jamiebadman  Sent: mardi 4 octobre 2005 11:34 
 To: flexcoders@yahoogroups.com  Subject: [flexcoders] Re: 
Number("011") = 9 It's performing an 
octal to decimal conversion. You can use the  Number class to 
convert between various different number bases.   
Jamie.   --- In flexcoders@yahoogroups.com, Christoph 
Diefenthal  [EMAIL PROTECTED] wrote:   Does 
anyone know why this happens??? Try it on 
your own server :  
   
mx:Application  xmlns:mx="http://www.macromedia.com/2003/mxml" 
  mx:Button 
label="Value Of String" click="valueOfString  ()" /  
 mx:Script 
  
![CDATA[  
 import 
mx.controls.Button;
 public function 
valueOfString():Void  
 {  
  
 // 
the result is 9 ?  
 
mx.controls.Alert.show("" + Number("011"));
 }  
 ]] 
  
/mx:Script   
/mx:Application
  --  Flexcoders Mailing List  FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt 
 Search Archives: http://www.mail- 
archive.com/flexcoders%40yahoogroups.com   
   SPONSORED LINKS  Web site design 
development  http://groups.yahoo.com/gads?t=msk=Web+site+design+developmentw1=Web+si 
 
te+design+developmentw2=Computer+software+developmentw3=Software+design+ 
 
and+developmentw4=Macromedi

RE: [flexcoders] Re: Number(011) = 9 ????

2005-10-05 Thread Blake Kadatz
You might want to alter Abdul's function slightly if you expect more
than one leading zero:

function getDecimalNumber(numStr:String):Number
{
if(numStr.indexOf(0)== 0)
{
return getDecimalNumber(numStr.substr(1));
}

return Number(numStr);
}


Cheers,

Blake


 Yahoo! Groups Sponsor ~-- 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/nhFolB/TM
~- 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
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] Re: Number(011) = 9 ????

2005-10-04 Thread Gordon Smith
If you do parseInt(011, 10), I'm pretty sure what happens is this:

1. The octal literal 011 is compiled as the decimal Number 9.
2. It is converted at runtime to the string 9, because parseInt expects to 
parse a string.
3. parseInt parses 9 to produce 9.

Obviously, this is a waste of time. 011 already *is* 9 at compile time. It is 
just a different way of writing it, just like 0x09 is a different way of 
writing it. For example, try this:

trace(011 - 1);

The output is 8.

- Gordon


-Original Message-
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Abdul 
Qabiz
Sent: Tuesday, October 04, 2005 10:29 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Re: Number(011) = 9 

Hi,

What do you want to do?

Convert 011 to decimal 11

Or convert octal(11) to decimal(9)

parseInt(..) is a global function and first argument is an expression, so you 
can pass number also:

parseInt(011, 10) - 9 (decimal)

You can look at Flash Player ActionScript on:

http://livedocs.macromedia.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part_ASLR.html


-abdul
 

-Original Message-
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of 
Christoph Diefenthal
Sent: Tuesday, October 04, 2005 7:34 PM
To: 'flexcoders@yahoogroups.com'
Subject: AW: [flexcoders] Re: Number(011) = 9 

Ok thank you all, 

I workaround (or isn't it a workaround??) this problem by using
parseInt(011, 10) to get the decimal-system value.

How can I use the Number-class to convert the values?
Is there a 
Number.parseInt() function?

There is no such function mentioned in the Flex ActionScript Language
Reference... can you provide me with a better API?


Cheers
Christoph



 -Ursprüngliche Nachricht-
 Von: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] Im
 Auftrag von Philippe Maegerman
 Gesendet: Dienstag, 4. Oktober 2005 12:24
 An: flexcoders@yahoogroups.com
 Betreff: RE: [flexcoders] Re: Number(011) = 9 
 
 If they are all octal numbers, you can use
 mx.controls.Alert.show( + Number(011).toString(8));
 
 Philippe Maegerman
 
 
 
 From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
 Behalf Of jamiebadman
 Sent: mardi 4 octobre 2005 11:34
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] Re: Number(011) = 9 
 
 
 It's performing an octal to decimal conversion. You can use the
 Number class to convert between various different number bases.
 
 Jamie.
 
 --- In flexcoders@yahoogroups.com, Christoph Diefenthal
 [EMAIL PROTECTED] wrote:
  Does anyone know why this happens???
 
  Try it on your own server  :
 
 
 
mx:Application
 xmlns:mx=http://www.macromedia.com/2003/mxml;
  mx:Button label=Value Of String click=valueOfString
 () /
  mx:Script
![CDATA[
import mx.controls.Button;
 
public function valueOfString():Void
{
 
  // the result is 9 ?
 mx.controls.Alert.show( + Number(011));
 
}
]]
  /mx:Script
/mx:Application
 
 
 
 
 --
 Flexcoders Mailing List
 FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
 Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
 
 
 
 
 SPONSORED LINKS
 Web site design development
 http://groups.yahoo.com/gads?t=msk=Web+site+design+developmentw1=Web+si
 te+design+developmentw2=Computer+software+developmentw3=Software+design+
 and+developmentw4=Macromedia+flexw5=Software+development+best+practicec
 =5s=166.sig=L-4QTvxB_quFDtMyhrQaHQ Computer software
development
 http://groups.yahoo.com/gads?t=msk=Computer+software+developmentw1=Web+
 site+design+developmentw2=Computer+software+developmentw3=Software+desig
 n+and+developmentw4=Macromedia+flexw5=Software+development+best+practice
 c=5s=166.sig=lvQjSRfQDfWudJSe1lLjHw   Software design and
development
 http://groups.yahoo.com/gads?t=msk=Software+design+and+developmentw1=We
 b+site+design+developmentw2=Computer+software+developmentw3=Software+des
 ign+and+developmentw4=Macromedia+flexw5=Software+development+best+practi
 cec=5s=166.sig=1pMBCdo3DsJbuU9AEmO1oQ
 Macromedia flex
 http://groups.yahoo.com/gads?t=msk=Macromedia+flexw1=Web+site+design+de
 velopmentw2=Computer+software+developmentw3=Software+design+and+developm
 entw4=Macromedia+flexw5=Software+development+best+practicec=5s=166.si
 g=OO6nPIrz7_EpZI36cYzBjw Software development best practice
 http://groups.yahoo.com/gads?t=msk=Software+development+best+practicew1
 =Web+site+design+developmentw2=Computer+software+developmentw3=Software+
 design+and+developmentw4=Macromedia+flexw5=Software+development+best+pra
 cticec=5s=166.sig=f89quyyulIDsnABLD6IXIw
 
 
 
 YAHOO! GROUPS LINKS
 
 
 
 *  Visit your group flexcoders
 http://groups.yahoo.com/group/flexcoders  on the web.
 
 *  To unsubscribe from this group, send an email to:
[EMAIL