Closed Thread
Results 1 to 8 of 8

Thread: How do you read time as a double?

  1. #1
    j.lai is offline Newbie
    Join Date
    Dec 2009
    Posts
    21
    Rep Power
    0

    How do you read time as a double?

    So I have an infile that I have to read a double but it is shown in time format.

    so for example, it says 3:00 but I need it to be read as a double. How would I scan it as a double?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: How do you read time as a double?

    You may need to read it as time or string and convert it to double. What should 3:00 be interpretted as in double form?
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    j.lai is offline Newbie
    Join Date
    Dec 2009
    Posts
    21
    Rep Power
    0

    Re: How do you read time as a double?

    It's for an assignment I have to do, I have to scan it as a double. I was thinking of reading it as a string then converting it as a double. I would have to replace the ":" to a "." though correct?

  5. #4
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: How do you read time as a double?

    Are you saying 3:00 = 3.00? I would think 3:00 = 0.125.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  6. #5
    agnl666's Avatar
    agnl666 is offline Programmer
    Join Date
    Feb 2010
    Location
    Halifax
    Posts
    163
    Blog Entries
    2
    Rep Power
    0

    Re: How do you read time as a double?

    I got lost right their. Could you explain why 3:00 = .125 ? I would say either 3:00 = 180min * 1 hr / 60min = 3.00 hr. or 3:00 = 18 (15th or third hour in the day) and then would proceed with 15:00 = 900 min * 1 hr / 60min = 15.00 hr.

  7. #6
    QuackWare is offline Learning Programmer
    Join Date
    Jan 2010
    Posts
    95
    Rep Power
    8

    Re: How do you read time as a double?

    You could do something like this.

    Code:
    String time = "3:00";
    time = time.replace(":",".");
    double timeDouble = Double.parseDouble(time);

  8. #7
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: How do you read time as a double?

    3:00 am = 3/24 = 1/8 = 0.125.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  9. #8
    agnl666's Avatar
    agnl666 is offline Programmer
    Join Date
    Feb 2010
    Location
    Halifax
    Posts
    163
    Blog Entries
    2
    Rep Power
    0

    Re: How do you read time as a double?

    Oh, that makes sense.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 7
    Last Post: 10-12-2011, 06:24 AM
  2. Replies: 0
    Last Post: 09-17-2011, 10:34 AM
  3. howdy! long time listener first time caller
    By darkresearcher in forum Introductions
    Replies: 2
    Last Post: 05-31-2011, 04:20 PM
  4. Replies: 1
    Last Post: 03-31-2010, 10:46 PM
  5. TASM How to read file by 100bytes each time? plz help
    By thatsme in forum Assembly
    Replies: 7
    Last Post: 11-25-2009, 11:08 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts