On Thu, 26 Nov 2020 17:07:44 +0200, Steff Gladstone  wrote:
>
>> On Monday, September 3, 2007 at 4:38:21 PM UTC-7, Ludmila Koganer wrote:
>> > Hi,
>> > I need to subtract two TOD times to find elapsed time. Currently I convert
>> > the two TOD times with STCKCONV and determine the elaped time individually,
>> > and then compute the difference. This works. However I thought I could 
>> >
Subtracting converted times is certainly the long way around:
    borrow negative seconds from minutes; borrow negative
    minutes from hours; "Thirty days hath September ..."

>> > optimize the conversion, a little bit and I was wondering why not subtract 
>> > the
>> > two TOD times to begin with.
>> >
>> > As I understand TOD time is the number of mic seconds elapsed since 
>> > midnight
>> > of 1900-01-01. So when I subtract one TOD value from another the duration
>> > must be in micro seconds.
>
Actually. microseconds/4096.

> I'm 11 years late. Shouldn't you clear the low order 12 bits of each TOD
>value before adding or subtracting them? Those low order bits are not
>fractions of a microsecond, so including them in the math can produce up to
>a micro second error. If you add a series of TOD values without clearing
>the low bits that can add up to real money.
>
I see little reason to add two or more time values in whatever format:
    1984 CE + 2020 CE = 4004 ???

In one convention, the low order bits of the (E)TOD clock contain the
CPU ID.  So, yes if the two TOD values are taken on different CPUs, an
error is possible.

STCKCONV of the difference of two plausible TOD values is likely to show
a date/time in 1900 CE.

-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to