Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

trimming a long in java

Options
  • 25-11-2003 6:45pm
    #1
    Closed Accounts Posts: 1,152 ✭✭✭


    hey all,

    i have this problem with my java program. i have to limit the number of digits in a long to 10, i have thought of ways to do this such as checking if the number is greater than 999,999,999. would this work?

    any help much appreciated


Comments

  • Hosted Moderators Posts: 2,094 ✭✭✭halenger


    You're problem there would be this:

    99.9999999999999 etc would always be smaller than 999,999,999!

    instead of checking the size of try:

    [PHP]if (long.toString().length() < 10)
    proceed;[/PHP]

    Hope this suits you.


  • Closed Accounts Posts: 1,152 ✭✭✭sound_wave


    thanks halenger, that worked a treat. thanks once again


Advertisement