471,870 Members | 1,340 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,870 software developers and data experts.

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 20685
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
reply views Thread by YellowAndGreen | last post: by
aboka
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.