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

Java: Number to microseconds to decimal.

Options
  • 20-09-2013 11:54am
    #1
    Registered Users Posts: 3,992 ✭✭✭


    Mind is somewhat melted and Google is failing me as i cant seem to form a proper search for this.

    So i have a number of microseconds.

    1 microsecond is 0.000001

    How do I do this in java without messing around with strings etc ?

    So:

    123 -> 0.000123
    2343 -> 0.002343
    56473 -> 0.056473

    Cheers


Comments

  • Closed Accounts Posts: 167 ✭✭dsrckiyisvddht


    Divide it by 1 million?
    int toMicro(int number){
    return number/1000000
    }
    


  • Registered Users Posts: 3,992 ✭✭✭Korvanica


    Divide it by 1 million?
    int toMicro(int number){
    return number/1000000
    }
    

    Sweet seems good. thanks man...


  • Closed Accounts Posts: 167 ✭✭dsrckiyisvddht


    Korvanica wrote: »
    Sweet seems good. thanks man...
    Dont forget to use float/double instead of int or ;

    :P


Advertisement