Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.acorn.programmer > #6078

Re: Subtracting times

From David Higton <dave@davehigton.me.uk>
Newsgroups comp.sys.acorn.programmer
Subject Re: Subtracting times
Date 2020-04-23 20:57 +0100
Organization Home
Message-ID <306fdc6558.DaveMeUK@BeagleBoard-xM> (permalink)
References (8 earlier) <20365a4958.Alan.Adams@ArmX6.adamshome.org.uk> <69d8792f-18c1-4a2c-8e14-0a7e0fd698c7@googlegroups.com> <586569f352News03@avisoft.f9.co.uk> <dccbb754-a167-43b8-ad2f-f6d82fbbd68b@googlegroups.com> <5865cc4b9aNews03@avisoft.f9.co.uk>

Show all headers | View raw


In message <5865cc4b9aNews03@avisoft.f9.co.uk>
          Martin <News03@avisoft.f9.co.uk> wrote:

> On 23 Apr in article
> <dccbb754-a167-43b8-ad2f-f6d82fbbd68b@googlegroups.com>,
>   <jeffrey.a.doggett@gmail.com> wrote:
> > On Thursday, 23 April 2020 00:09:59 UTC+1, Martin  wrote:
> > > On 22 Apr in article
> > > <69d8792f-18c1-4a2c-8e14-0a7e0fd698c7@googlegroups.com>,
> > >    <jeffrey.a.doggett@gmail.com> wrote:
> > > > Sorry that I'm late to the party here. In order to calculate the
> > > > elapsed time you can just subtract the lower 4 bytes.
> > > 
> > > > So if Start% is the lower four bytes of the start time & Finish% is
> > > > the lower four bytes of the finish time:
> > > 
> > > > TimeTaken% = Finish% - Start%
> > > 
> > > > This "Just works" and will always produce the correct result even
> > > > with rollovers.
> > > 
> > > > If TimeTaken% < 0 then the finish was before the start.
> > > 
> > > I don't think this works if the time difference is over 35 weeks....
> 
> > No, but Alan is timing a canoeist down a slalom course.  If it takes 35
> > weeks then there's something amiss.
> 
> Indeed. But what happens when the 5-byte hex times are...
>    start time =  58 00 00 04 00
>    end time   =  57 00 00 05 00 gives x100 ... when it should be flagged as
> negative and duff!

As has already been pointed out, the answers are all correct within a
certain range of times, something like 35 weeks, which is orders of
magnitude greater than can happen in this use case.

It's not a general solution, but it is entirely correct and appropriate
for what the OP's needs.

David

Back to comp.sys.acorn.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Subtracting times Alan Adams <alan@adamshome.org.uk> - 2020-02-18 11:55 +0000
  Re: Subtracting times Jean-Michel <jmc.bruck@orange.fr> - 2020-02-18 19:11 +0100
    Re: Subtracting times Steve Drain <steve@kappa.me.uk> - 2020-02-21 03:28 -0800
      Re: Subtracting times Alan Adams <alan@adamshome.org.uk> - 2020-02-21 12:45 +0000
      Re: Subtracting times Alan Adams <alan@adamshome.org.uk> - 2020-02-21 15:17 +0000
        Re: Subtracting times Steve Drain <steve@kappa.me.uk> - 2020-02-22 10:37 +0000
          Re: Subtracting times Steve Drain <steve@kappa.me.uk> - 2020-02-25 16:05 +0000
            Re: Subtracting times Alan Adams <alan@adamshome.org.uk> - 2020-02-25 16:35 +0000
              Re: Subtracting times Steve Drain <steve@kappa.me.uk> - 2020-02-27 17:10 +0000
                Re: Subtracting times Steve Drain <steve@kappa.me.uk> - 2020-02-27 10:06 -0800
                Re: Subtracting times Alan Adams <alan@adamshome.org.uk> - 2020-02-28 11:21 +0000
                Re: Subtracting times jeffrey.a.doggett@gmail.com - 2020-04-22 12:00 -0700
                Re: Subtracting times Martin <News03@avisoft.f9.co.uk> - 2020-04-23 00:07 +0100
                Re: Subtracting times jeffrey.a.doggett@gmail.com - 2020-04-23 03:13 -0700
                Re: Subtracting times Martin <News03@avisoft.f9.co.uk> - 2020-04-23 18:01 +0100
                Re: Subtracting times "John Williams (News)" <UCEbin@tiscali.co.uk> - 2020-04-23 18:06 +0100
                Re: Subtracting times jeffrey.a.doggett@gmail.com - 2020-04-23 11:18 -0700
                Re: Subtracting times Martin <News03@avisoft.f9.co.uk> - 2020-04-23 21:23 +0100
                Re: Subtracting times David Higton <dave@davehigton.me.uk> - 2020-04-24 15:24 +0100
                Re: Subtracting times David Higton <dave@davehigton.me.uk> - 2020-04-23 20:57 +0100
        Re: Subtracting times jgh@mdfs.net - 2020-02-23 17:39 -0800
          Re: Subtracting times Steve Drain <steve@kappa.me.uk> - 2020-02-24 10:23 +0000
            Re: Subtracting times Alan Adams <alan@adamshome.org.uk> - 2020-02-24 11:12 +0000
              Re: Subtracting times Martin <News03@avisoft.f9.co.uk> - 2020-02-24 13:05 +0000
  Re: Subtracting times Matthew Phillips <spam2011m@yahoo.co.uk> - 2020-02-19 08:35 +0000
    Re: Subtracting times Alan Adams <alan@adamshome.org.uk> - 2020-02-19 10:03 +0000
      Re: Subtracting times Sebastian Barthel <naitsabes@freenet.de> - 2020-02-19 13:04 +0000
        Re: Subtracting times Alan Adams <alan@adamshome.org.uk> - 2020-02-19 16:41 +0000
          Re: Subtracting times jgh@mdfs.net - 2020-02-19 12:01 -0800
      Re: Subtracting times Matthew Phillips <spam2011m@yahoo.co.uk> - 2020-02-23 20:46 +0000
  Re: Subtracting times Martin <News03@avisoft.f9.co.uk> - 2020-02-19 23:54 +0000
    Re: Subtracting times Alan Adams <alan@adamshome.org.uk> - 2020-02-20 11:18 +0000

csiph-web