469,338 Members | 8,718 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,338 developers. It's quick & easy.

How to find No. of Digits in a number

Hi every one,
Please tell me How to find No. of Digits in a number using java program?
Aug 4 '07 #1
3 20598
JosAH
11,448 Expert 8TB
Hi every one,
Please tell me How to find No. of Digits in a number using java program?
Just count them; you can either do that numerically (divide by ten all the time)
or make a string out of that number and check the string length. These tips
should be enough for you to cook up a nice little method that does the job.

kind regards,

Jos
Aug 4 '07 #2
Just count them; you can either do that numerically (divide by ten all the time)
or make a string out of that number and check the string length. These tips
should be enough for you to cook up a nice little method that does the job.

kind regards,

Jos

Hi,

Thanks a lot. I used the (String.valueOf(num)).length(). Its working.
Aug 6 '07 #3
JosAH
11,448 Expert 8TB
Hi,

Thanks a lot. I used the (String.valueOf(num)).length(). Its working.
Watch out for negative numbers though.

kind regards,

Jos
Aug 6 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

debasisdas
5 posts views Thread by debasisdas | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.