Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Java: Number to microseconds to decimal.

  • 20-09-2013 10:54AM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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