=?ISO-2022-JP?B?UmU6IFtzcXVlYWstZGV2XSBbQlVHXSBzaWduZWRMb25nQXQ6?=
=?ISO-2022-JP?B?IDEgcHV0OhskQiFdGyhCMiwxNDcsNDgzLDY0OA==?=
John M McIntosh
johnmci at smalltalkconsulting.com
Tue Dec 2 20:04:12 UTC 2008
Eliot thanks for this. I went with
(negative and: [value = (1<<31)])
ifTrue: [^value].
versus
(negative and: [value - 1 > 0])
ifTrue: [^value].
I had hardcoded -2147483648 but got some ansi 99 compiler warning so I
did the shift, I'd *think* the compiler will do the 1<<31 constant
resolving
and use the final value so we only have the compare, versus a
subtraction and compare. Not that you could measure any performance
differences
In the Alien Sunits I cover the cases of 0 4294967295 -2147483648
2147483647 (for signed/unsigned)
then do random sampling (10,000) elements of
unsignedIntegerIntervalue := (0 to: 4294967295).
signedIntegerIntervalue := (-2147483648 to: 2147483647).
signedIntegerIntervalue := (-4294967295 to: -2147483649). should
prim value
signedIntegerIntervalue := (2147483648 to: 4294967295). should prim
fail
If someone wants to try they could run *all* the values from
-0xFFFFFFFF 0xFFFFFFFF just to confirm *every* value works as
expected since that would
only take a few hours or less on the fast machines today.
I note I do the 0xFFFFFFFF * (-1) because it's possible someone might
pass that in and ask for a signed integer, in that case we of course
fail until we
reach the lowest 32bit signed integer value of -2147483648 (I so I
assume) since I've not run the entire range, which is feasible.
Obviously running the 64bit range could take a while. Anyone want to
estimate?
On 2-Dec-08, at 11:32 AM, Eliot Miranda wrote:
> Hi John,
>
> here's the fix for signed32BitValueOf:
>
>
> On Tue, Nov 25, 2008 at 11:15 PM, John M McIntosh <johnmci at smalltalkconsulting.com
> > wrote:
--
=
=
=
========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com>
Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com
=
=
=
========================================================================
More information about the Squeak-dev
mailing list
|