Number conversion


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2006
    Location
    Lazio, Italy
    Posts
    41

    Default Number conversion

    I need to convert some numbers that express time values ​​from decimal to sexagesimal . Does anyone have a valid formula ? thanks

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: Number conversion

    How To Convert a Decimal to Sexagesimal

    http://geography.about.com/library/howto/htdegrees.htm

    Does this help?

    Robert

  3. #3
    Join Date
    Jul 2006
    Location
    Lazio, Italy
    Posts
    41


    Did you find this post helpful? Yes | No

    Default Re: Number conversion

    Thanks Demon, maybe I have not explained well, but I have a number of hours expressed as a decimal (eg. 2.5h - 4,23h - 1,125h) and I need to convert this number in hours: minutes: seconds (HH: MM : ss). Thank you for your help

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Number conversion

    Hi Mombassa
    in PBP you will have to jump through several hoops like a circus dog
    hours to seconds = hours x 3600
    minutes to seconds = minutes x 60

    seconds to hours = seconds /3600 with no remainder or seconds//3600 with a remainder
    minutes= seconds//60 with remainder being your seconds left over
    see section 4.17.2 of the manual.
    you may display individual digits using DIG command sec 4.17.8
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Number conversion

    You will need .0001 hour resolution to get 1 second resolution.
    .1 hour = 6 min.
    .01 hour = 24 sec.
    .001 hour = 3.6 sec
    .0001 hour = .36 sec
    Last edited by Dave; - 10th November 2014 at 19:07.
    Dave Purola,
    N8NTA
    EN82fn

  6. #6
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    198


    Did you find this post helpful? Yes | No

    Default Re: Number conversion

    It would appear, from your examples, that the hours are already done. As minutes and seconds share a base of 60 parts per whole [next] unit, you really only need consider one conversion from decimal fraction (hundredths) to time based (sixtieths) - once for the fraction of hours to minutes, then again on the remainder for fractions of minutes to seconds. Some scaling will be necessary to address the integer math, but...

    Fraction of an hour * 60 = minutes. Fraction of a minute * 60 = seconds.

    So, if you have 1.125 hours: .125 hours * 60 = 7.5 minutes and .5 minutes * 60 = 30 seconds. 1.125 hours = 01:07:30. Again using your example of 4.23 hours:

    .23 hours * 60 = 13.8 minutes. .8 minutes * 60 = 48 seconds = 04:13:48.

    Perhaps I have misunderstood your OP, but it does not seem such a difficult exercise to me.

  7. #7
    Join Date
    Jul 2006
    Location
    Lazio, Italy
    Posts
    41


    Did you find this post helpful? Yes | No

    Smile Re: Number conversion

    Thanks to all for the invaluable assistance

Similar Threads

  1. number match selection
    By longpole001 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 17th April 2014, 05:55
  2. Generate a random number between 0 and X
    By The Master in forum Off Topic
    Replies: 7
    Last Post: - 15th September 2010, 10:52
  3. String to number conversion
    By dj.lambert in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 14th September 2010, 22:29
  4. Is Number Odd?
    By T.Jackson in forum Off Topic
    Replies: 29
    Last Post: - 11th June 2008, 17:53

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

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