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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

trimming a long in java

  • 25-11-2003 5: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