Re: off topic - how do i convert an int to char

2004-12-07 Thread Yang Xiao
make a hash or array?


On Tue, 7 Dec 2004 10:34:15 -0500, Nilesh Bhattad [EMAIL PROTECTED] wrote:
 folks,
 sorry for posting this offtopic qns here.. but would someone plz help me out 
 in converting an int value to char? my requirement is very simple. i'm 
 looping thro a list and for each counter i need to get 'a', 'b' and so forth.
 
 basically i need some conversion routine which will convert 0 to 'a', 1 to 
 'b', 2 to 'c' and so on.
 
 again, i apologize for posting such a dumb qns.
 
 - nilesh


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: off topic - how do i convert an int to char

2004-12-07 Thread Brantley Hobbs
Alternatively, you can add the ASCII offset to the integer, then get the
char that evaluates to that ASCII code.  I think its 32, but you'll need
to check for sure.

B.



 -Original Message-
 From: Yang Xiao [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, December 07, 2004 10:42 AM
 To: Tomcat Users List
 Subject: Re: off topic - how do i convert an int to char
 
 make a hash or array?
 
 
 On Tue, 7 Dec 2004 10:34:15 -0500, Nilesh Bhattad
[EMAIL PROTECTED]
 wrote:
  folks,
  sorry for posting this offtopic qns here.. but would someone plz
help me
 out in converting an int value to char? my requirement is very simple.
i'm
 looping thro a list and for each counter i need to get 'a', 'b' and so
 forth.
 
  basically i need some conversion routine which will convert 0 to
'a', 1
 to 'b', 2 to 'c' and so on.
 
  again, i apologize for posting such a dumb qns.
 
  - nilesh
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: off topic - how do i convert an int to char

2004-12-07 Thread Nilesh Bhattad
That would be the last solution if i dont get any other better way of doing 
it... i tried with Character.forDigit(97, 2) hoping to get 'a' back but it 
returned 0... i'm not sure which radix does it expect as a 2nd argument.

btw Yang, thanks for quick response.
- nilesh
- Original Message - 
From: Yang Xiao [EMAIL PROTECTED]
To: Tomcat Users List [EMAIL PROTECTED]
Sent: Tuesday, December 07, 2004 10:42 AM
Subject: Re: off topic - how do i convert an int to char


make a hash or array?
On Tue, 7 Dec 2004 10:34:15 -0500, Nilesh Bhattad [EMAIL PROTECTED] 
wrote:
folks,
sorry for posting this offtopic qns here.. but would someone plz help me 
out in converting an int value to char? my requirement is very simple. 
i'm looping thro a list and for each counter i need to get 'a', 'b' and 
so forth.

basically i need some conversion routine which will convert 0 to 'a', 1 
to 'b', 2 to 'c' and so on.

again, i apologize for posting such a dumb qns.
- nilesh
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: off topic - how do i convert an int to char

2004-12-07 Thread Brantley Hobbs
Wow, was I off.

Add a 97 to your int value to get the lower-case English letters.

B.

 -Original Message-
 From: Brantley Hobbs
 Sent: Tuesday, December 07, 2004 10:50 AM
 To: Tomcat Users List; Yang Xiao
 Subject: RE: off topic - how do i convert an int to char
 
 Alternatively, you can add the ASCII offset to the integer, then get
the
 char that evaluates to that ASCII code.  I think its 32, but you'll
need
 to check for sure.
 
 B.
 
 
 
  -Original Message-
  From: Yang Xiao [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, December 07, 2004 10:42 AM
  To: Tomcat Users List
  Subject: Re: off topic - how do i convert an int to char
 
  make a hash or array?
 
 
  On Tue, 7 Dec 2004 10:34:15 -0500, Nilesh Bhattad
 [EMAIL PROTECTED]
  wrote:
   folks,
   sorry for posting this offtopic qns here.. but would someone plz
 help me
  out in converting an int value to char? my requirement is very
simple.
 i'm
  looping thro a list and for each counter i need to get 'a', 'b' and
so
  forth.
  
   basically i need some conversion routine which will convert 0 to
 'a', 1
  to 'b', 2 to 'c' and so on.
  
   again, i apologize for posting such a dumb qns.
  
   - nilesh
  
 
 
-
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: off topic - how do i convert an int to char

2004-12-07 Thread Peter Crowther
 From: Nilesh Bhattad [mailto:[EMAIL PROTECTED] 
 Subject: Re: off topic - how do i convert an int to char

Oh, come on.

String letterAt(int i) {
   return abcdefghijklmnopqrstuvwxyz.substring(i, i + 1);
}

Fast, portable, simple.

- Peter

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: off topic - how do i convert an int to char

2004-12-07 Thread Nilesh Bhattad
Thanks!!!
that worked !!
- Original Message - 
From: Brantley Hobbs [EMAIL PROTECTED]
To: Tomcat Users List [EMAIL PROTECTED]; Yang Xiao 
[EMAIL PROTECTED]
Sent: Tuesday, December 07, 2004 10:54 AM
Subject: RE: off topic - how do i convert an int to char

Wow, was I off.
Add a 97 to your int value to get the lower-case English letters.
B.
-Original Message-
From: Brantley Hobbs
Sent: Tuesday, December 07, 2004 10:50 AM
To: Tomcat Users List; Yang Xiao
Subject: RE: off topic - how do i convert an int to char
Alternatively, you can add the ASCII offset to the integer, then get
the
char that evaluates to that ASCII code.  I think its 32, but you'll
need
to check for sure.
B.

 -Original Message-
 From: Yang Xiao [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, December 07, 2004 10:42 AM
 To: Tomcat Users List
 Subject: Re: off topic - how do i convert an int to char

 make a hash or array?


 On Tue, 7 Dec 2004 10:34:15 -0500, Nilesh Bhattad
[EMAIL PROTECTED]
 wrote:
  folks,
  sorry for posting this offtopic qns here.. but would someone plz
help me
 out in converting an int value to char? my requirement is very
simple.
i'm
 looping thro a list and for each counter i need to get 'a', 'b' and
so
 forth.
 
  basically i need some conversion routine which will convert 0 to
'a', 1
 to 'b', 2 to 'c' and so on.
 
  again, i apologize for posting such a dumb qns.
 
  - nilesh
 


-
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: off topic - how do i convert an int to char

2004-12-07 Thread Robert Harper
The offset starts at '0' == 48 ( 0x30 hex ) for ASCII. To get the correct
values, you should know what character set you are in.

Robert S. Harper
801.265.8800 ex. 255
 -Original Message-
 From: Brantley Hobbs [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, December 07, 2004 8:50 AM
 To: Tomcat Users List; Yang Xiao
 Subject: RE: off topic - how do i convert an int to char
 
 Alternatively, you can add the ASCII offset to the integer, then get the
 char that evaluates to that ASCII code.  I think its 32, but you'll need
 to check for sure.
 
 B.
 
 
 
  -Original Message-
  From: Yang Xiao [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, December 07, 2004 10:42 AM
  To: Tomcat Users List
  Subject: Re: off topic - how do i convert an int to char
 
  make a hash or array?
 
 
  On Tue, 7 Dec 2004 10:34:15 -0500, Nilesh Bhattad
 [EMAIL PROTECTED]
  wrote:
   folks,
   sorry for posting this offtopic qns here.. but would someone plz
 help me
  out in converting an int value to char? my requirement is very simple.
 i'm
  looping thro a list and for each counter i need to get 'a', 'b' and so
  forth.
  
   basically i need some conversion routine which will convert 0 to
 'a', 1
  to 'b', 2 to 'c' and so on.
  
   again, i apologize for posting such a dumb qns.
  
   - nilesh
  
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: off topic - how do i convert an int to char

2004-12-07 Thread Brantley Hobbs
These other guys are correct.  You should do it with a mind toward
portability if you can.  Sometimes I slip into my old-school C and ASM
ways!  :-)

I really liked Peter's method.

B.



 -Original Message-
 From: Nilesh Bhattad [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, December 07, 2004 11:01 AM
 To: Brantley Hobbs; Yang Xiao
 Cc: Tomcat Users List
 Subject: Re: off topic - how do i convert an int to char
 
 Thanks!!!
 that worked !!
 
 - Original Message -
 From: Brantley Hobbs [EMAIL PROTECTED]
 To: Tomcat Users List [EMAIL PROTECTED]; Yang Xiao
 [EMAIL PROTECTED]
 Sent: Tuesday, December 07, 2004 10:54 AM
 Subject: RE: off topic - how do i convert an int to char
 
 
 Wow, was I off.
 
 Add a 97 to your int value to get the lower-case English letters.
 
 B.
 
  -Original Message-
  From: Brantley Hobbs
  Sent: Tuesday, December 07, 2004 10:50 AM
  To: Tomcat Users List; Yang Xiao
  Subject: RE: off topic - how do i convert an int to char
 
  Alternatively, you can add the ASCII offset to the integer, then get
 the
  char that evaluates to that ASCII code.  I think its 32, but you'll
 need
  to check for sure.
 
  B.
 
 
 
   -Original Message-
   From: Yang Xiao [mailto:[EMAIL PROTECTED]
   Sent: Tuesday, December 07, 2004 10:42 AM
   To: Tomcat Users List
   Subject: Re: off topic - how do i convert an int to char
  
   make a hash or array?
  
  
   On Tue, 7 Dec 2004 10:34:15 -0500, Nilesh Bhattad
  [EMAIL PROTECTED]
   wrote:
folks,
sorry for posting this offtopic qns here.. but would someone plz
  help me
   out in converting an int value to char? my requirement is very
 simple.
  i'm
   looping thro a list and for each counter i need to get 'a', 'b'
and
 so
   forth.
   
basically i need some conversion routine which will convert 0 to
  'a', 1
   to 'b', 2 to 'c' and so on.
   
again, i apologize for posting such a dumb qns.
   
- nilesh
   
  
  
 -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail:
[EMAIL PROTECTED]
 
 
 
 
-
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: off topic - how do i convert an int to char

2004-12-07 Thread Parsons Technical Services
Cast it with the offset added.
int i = 0;
char ch = (char)(i+97);
Wrap in a try catch block if desired.
Doug
- Original Message - 
From: Nilesh Bhattad [EMAIL PROTECTED]
To: Tomcat Users List [EMAIL PROTECTED]; Yang Xiao 
[EMAIL PROTECTED]
Sent: Tuesday, December 07, 2004 10:51 AM
Subject: Re: off topic - how do i convert an int to char


That would be the last solution if i dont get any other better way of 
doing it... i tried with Character.forDigit(97, 2) hoping to get 'a' back 
but it returned 0... i'm not sure which radix does it expect as a 2nd 
argument.

btw Yang, thanks for quick response.
- nilesh
- Original Message - 
From: Yang Xiao [EMAIL PROTECTED]
To: Tomcat Users List [EMAIL PROTECTED]
Sent: Tuesday, December 07, 2004 10:42 AM
Subject: Re: off topic - how do i convert an int to char


make a hash or array?
On Tue, 7 Dec 2004 10:34:15 -0500, Nilesh Bhattad [EMAIL PROTECTED] 
wrote:
folks,
sorry for posting this offtopic qns here.. but would someone plz help me 
out in converting an int value to char? my requirement is very simple. 
i'm looping thro a list and for each counter i need to get 'a', 'b' and 
so forth.

basically i need some conversion routine which will convert 0 to 'a', 1 
to 'b', 2 to 'c' and so on.

again, i apologize for posting such a dumb qns.
- nilesh
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: off topic - how do i convert an int to char

2004-12-07 Thread Filip Hanik - Dev
am I being silly?

char ch = (char)myint;

Filip

- Original Message - 
From: Robert Harper [EMAIL PROTECTED]
To: 'Tomcat Users List' [EMAIL PROTECTED]
Sent: Tuesday, December 07, 2004 10:01 AM
Subject: RE: off topic - how do i convert an int to char


The offset starts at '0' == 48 ( 0x30 hex ) for ASCII. To get the correct
values, you should know what character set you are in.

Robert S. Harper
801.265.8800 ex. 255
 -Original Message-
 From: Brantley Hobbs [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, December 07, 2004 8:50 AM
 To: Tomcat Users List; Yang Xiao
 Subject: RE: off topic - how do i convert an int to char
 
 Alternatively, you can add the ASCII offset to the integer, then get the
 char that evaluates to that ASCII code.  I think its 32, but you'll need
 to check for sure.
 
 B.
 
 
 
  -Original Message-
  From: Yang Xiao [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, December 07, 2004 10:42 AM
  To: Tomcat Users List
  Subject: Re: off topic - how do i convert an int to char
 
  make a hash or array?
 
 
  On Tue, 7 Dec 2004 10:34:15 -0500, Nilesh Bhattad
 [EMAIL PROTECTED]
  wrote:
   folks,
   sorry for posting this offtopic qns here.. but would someone plz
 help me
  out in converting an int value to char? my requirement is very simple.
 i'm
  looping thro a list and for each counter i need to get 'a', 'b' and so
  forth.
  
   basically i need some conversion routine which will convert 0 to
 'a', 1
  to 'b', 2 to 'c' and so on.
  
   again, i apologize for posting such a dumb qns.
  
   - nilesh
  
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: off topic - how do i convert an int to char

2004-12-07 Thread Caldarale, Charles R
 From: Parsons Technical Services [mailto:[EMAIL PROTECTED]
 Subject: Re: off topic - how do i convert an int to char
 
 Cast it with the offset added.
 int i = 0;
 char ch = (char)(i+97);

Or if you want to make it a little more understandable:

char ch = (char) (i + 'a');

Note that the previously suggested use of the substring() method has two 
drawbacks: it returns a String, not a char as originally requested; and it 
creates a new String object every time it's called.  Both problems would be 
avoided by using charAt() rather than substring().  Still not as fast as the 
straight arithmetic shown above.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: off topic - how do i convert an int to char

2004-12-07 Thread Adam Smith
private static final char[] enc=abcdefghijklmnopqrstuvwxyz.toCharArray();

 for (int i=0;i26;i++)
System.out.print(enc[i]);

- Original Message -
From: Nilesh Bhattad [EMAIL PROTECTED]
To: Tomcat Users List [EMAIL PROTECTED]
Sent: Tuesday, December 07, 2004 10:34 AM
Subject: off topic - how do i convert an int to char


folks,
sorry for posting this offtopic qns here.. but would someone plz help me out
in converting an int value to char? my requirement is very simple. i'm
looping thro a list and for each counter i need to get 'a', 'b' and so
forth.

basically i need some conversion routine which will convert 0 to 'a', 1 to
'b', 2 to 'c' and so on.

again, i apologize for posting such a dumb qns.

- nilesh


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]