On 5 February 2011 21:59, michealbutz <[email protected]> wrote:
> I had to add
>
>    TOD1 = X2D( B2X( LEFT( X2B( C2X(RAWTOD) ),52) ) )

Whew - that's a complicated expression. But let's come back to it.

>  Since I got the data off the Evaluate command
>
> Just one question why shift left 12 bits

That's equivalent to a right shift - not a left one. The reason is
that the TOD clock is defined such that bit position 51 (we number the
leftmost bit 0, and the rightmost 63) is incremented every
microsecond. So if you think of the clock as a number comprising 64
binary digits (bits), with an implied binary point to the right of bit
51, then the first digit to the left of the point counts microseconds
(henceforth uS to keep it short), the next left counts 2 x uS, the
next 4 x uS, and so on. The first digit to the right of the point
counts uS/2, the next uS/4, and so on.

If a decimal analogue helps, imagine that I tell you there is, say, a
number comprising 10 decimal digits (we can call them dits), with an
implied decimal point between dits 6 and 7, and that this number
represents money. Then I could tell you that the first digit to the
left of the point counts dollars, and you would immediately understand
that the next left counts dollars x 10, the next counts dollars x 100,
and so on, and that the first digit to the right of the point counts
dimes, the next one right counts cents, and the next one counts tenths
of cents or mills.

On any given machine model the clock may count with greater or lesser
precision, but the effect is as though bit 51 were incremented every
uS, just as we might increment our money counter by dollars or cents
or even by 100-dollar chunks, without changing the fact that dit
position 6 represents dollars. For very many (doubtless most)
practical purposes, measuring elapsed time to the uS is Good Enough,
and it is quite a bit easier both conceptually and practically to do
decimal integer arithmetic with whole uS, then with binary fractions
of uS.

Now as to your REXX expression...  It seems correct, but you can make
it shorter, more efficient, and easier to understand. Since you want
to remove the rightmost 12 bits (i.e. keep the leftmost 52), and 12
just happens (heh) to be a multiple of 4, which is the number of bits
represented by a hex digit, you can avoid the conversion to REXX
binary and back, and remove the rightmost three hex digits instead.

TOD1 = X2D( LEFT( C2X( RAWTOD ),13 ) )

Tony H.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to