FILETIME class>>fromInteger: bug?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

FILETIME class>>fromInteger: bug?

Bill Schwab-2
Hi Blair,

Try

  FILETIME fromInteger:126661379535479952.

It looks like D4 was truncating the large integer argument where D5 does
not.  If I'm reading it correctly, the D5 behavior seems better, but some
kind of patch to FILETIME is required.

As MS would put it, "the following has not been fully regression tested, and
should be installed only if you are..." :)

Have a good one,

Bill


!FILETIME class methodsFor!

fromInteger: int64
 "Answer an instance of the receiver for the <integer>, i64, number
 of 100 nanosecond intervals since 01:00:00, 01 January 1601."

 #wksDangerous. "Tweaked 8-02:
  FILETIME fromInteger:126661379535479952.
  FILETIME fromInteger:126736479966323248.
  FILETIME fromInteger:126661379535580096.
 ^self new
  dwLowDateTime: int64;
  dwHighDateTime: (int64 bitShift: -32)
 "
 ^self new
  dwLowDateTime:( int64 bitAnd:16rFFFF );
  dwHighDateTime: (int64 bitShift: -32)
! !
!FILETIME class categoriesFor: #fromInteger:!instance creation!public! !


--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: FILETIME class>>fromInteger: bug?

Blair McGlashan
"Bill Schwab" <[hidden email]> wrote in message
news:aj8t95$1898qu$[hidden email]...
> Hi Blair,
>
> Try
>
>   FILETIME fromInteger:126661379535479952.
>
> It looks like D4 was truncating the large integer argument where D5 does
> not.  If I'm reading it correctly, the D5 behavior seems better, but some
> kind of patch to FILETIME is required.

Thanks Bill, recorded and fixed (for next release) as #1039.

>
> As MS would put it, "the following has not been fully regression tested,
and
> should be installed only if you are..." :)
>...

A suitable test, passing a range of inputs including boundary conditions
such as 0, 1, (2^32)-1, 2^32, (2^32)+1, (2^64)-1, and 2^64 (an error), might
be:

   self assert: (FILETIME fromInteger: anInteger) asInteger = (anInteger
bitAnd: 2 ** 64 - 1)

Negative inputs should probably be an error, but as they aren't currently
the test allows for this.

>
> fromInteger: int64
>  ^self new
>   dwLowDateTime:( int64 bitAnd:16rFFFF );
>   dwHighDateTime: (int64 bitShift: -32)

BTW: That bit mask should be (2^32)-1, i.e. 16rFFFFFFFF.

Regards

Blair


Reply | Threaded
Open this post in threaded view
|

Re: FILETIME class>>fromInteger: bug?

Bill Schwab-2
Blair,

> > fromInteger: int64
> >  ^self new
> >   dwLowDateTime:( int64 bitAnd:16rFFFF );
> >   dwHighDateTime: (int64 bitShift: -32)
>
> BTW: That bit mask should be (2^32)-1, i.e. 16rFFFFFFFF.

Thanks - late yesterday, I noticed that something wasn't quite right, but
hadn't completely ruled out time zone settings, etc.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]