:-) Jonathan, thank you for taking the time to respond.
> > On Mar 25, 11:03 am, Gerardo Santana <gerardo.sant...@gmail.com>
> > wrote:
[quoted text clipped - 106 lines]
> ndgts: 1
> dgts: 37 26 76 96 00 00 00 06 00
One base-100 digit is significant - the 37; the rest are ignored (I'd
prefer that they were zeroed, but that's life).
> an INTERVAL(3700) YEAR TO YEAR is stored like this:
> ndgts: 1
> dgts: 37 00 11 96 00 00 00 06
Of course; there is one significant centisimal (base-100) digit, the
37. The exponent is one large than for just 37 years. If you had
experimented with 370 years, you'd find ndgits = 2, and the values
would be 03 and 70 and the exponent would be the same as for 3700
years.
I've discussed decimal representations before in this news group - and
there's also code in SQLCMD for dumping decimals and intervals
(dumpdec.ec, dumpintvl.ec) and then there's the ivconv.ec code I
mentioned too.
> There's a difference is in the dec_exp part of course, that's what I'm
> using to work around this problem by the way.
>
> But my point is that I expected that the value of ndgts were 2 instead
> of 1 in the case of INTERVAL(3700) YEAR TO YEAR. I understood that I
> was supposed to extract ndgts entries from dgts.
ndgts counts centesimal digits, not decimal digits. The type is
arguably a misnomer (interestingly, that's the word of the day for one
of the online web sites that does that). However, although you
specify numbers of decimal digits, the storage uses centesimal digits,
so there's a factor of two difference, give or take the odd one.
> Since ndgts is not 2, I get 37 years in both cases.
>
> The workaround is ignoring ndgts and take as much digits as I need,
> according to the class of the INTERVAL of course (I'm extending all
> INTERVALs to either YEAR(9) TO MONTH or DAY(9) TO SECOND), with the
> help of dec_exp.
That's bad; you'll get junk if you do that. You have to treat the
value correctly. For some work I've been doing, I concluded that I
needed to unpack the decimal part of an interval into a fixed format
structure (actually, an array of unsigned bytes) where there was
enough space for any interval (or datetime) value. The implied
decimal point was in a fixed location. The only tricky bit is that if
an interval is DAY TO SECOND, then certain bytes contain day values,
but if the interval is HOUR TO SECOND, then some of the 'day' storage
locations contain extra digits of the hour part (for HOUR(4) TO
SECOND, the most significant pair of decimal digits, or single most
significant base-100 digit, occupy the space that would be taken by
the least significant digits of an INTERVAL DAY TO SECOND). But I
found that easier to manipulate than the floating decimal structure.
> Then the problem is that after extending the INTERVAL, as you can see
> in the first dump, there's "garbage" in the rest of the digits. So I
[quoted text clipped - 9 lines]
> Shouldn't this be documented?, or, where am I wrong in my
> suppositions?
Debatable whether it 'should' be documented. Nominally, you use the
ESQL/C functions to handle the type. However, they are not as
complete as you'd like, so you have to delve into the details like
this.
> I'm using the following documentation:
...dropped...
Version 10 - OK; the details haven't changed.
> By the way, I've reported a pair of errors in the documentation but
> I'm not sure if it has reached someone because I haven't got any
> answer.
The docinf@us.ibm.com mail alias has had problems recently -
apparently.
Send the messages to me, please, and I'll forward them to Tech Pubs.
HTH.
-=JL=-
Gerardo Santana - 26 Mar 2008 20:43 GMT
> > According to thishttp://publib.boulder.ibm.com/infocenter/idshelp/v111/topic/com.ibm.e...
>
[quoted text clipped - 6 lines]
> One base-100 digit is significant - the 37; the rest are ignored (I'd
> prefer that they were zeroed, but that's life).
Ouch. I see my mistake now. How embarrassing.
Thanks Jonathan.
> > By the way, I've reported a pair of errors in the documentation but
> > I'm not sure if it has reached someone because I haven't got any
[quoted text clipped - 3 lines]
> apparently.
> Send the messages to me, please, and I'll forward them to Tech Pubs.
Sure.