<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 17, 2014 at 1:22 PM, Chris Muller <span dir="ltr"><<a href="mailto:ma.chris.m@gmail.com" target="_blank">ma.chris.m@gmail.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">> On Wed, Dec 17, 2014 at 11:23 AM, Chris Muller <<a href="mailto:asqueaker@gmail.com">asqueaker@gmail.com</a>> wrote:<br>
>><br>
>> On Wed, Dec 17, 2014 at 12:55 PM, Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>><br>
>> wrote:<br>
>> > Hi Chris,<br>
>> ><br>
>> > On Dec 17, 2014, at 9:17 AM, Chris Muller <<a href="mailto:asqueaker@gmail.com">asqueaker@gmail.com</a>> wrote:<br>
>> ><br>
>> >> On Wed, Dec 17, 2014 at 12:20 AM, Eliot Miranda<br>
>> >> <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>> wrote:<br>
>> >>> Hi Chris,<br>
>> >>><br>
>> >>> On Dec 16, 2014, at 7:24 PM, Chris Muller <<a href="mailto:asqueaker@gmail.com">asqueaker@gmail.com</a>> wrote:<br>
>> >>><br>
>> >>>> I wish to access some of the Float constants without a message send.<br>
>> >>><br>
>> >>> I'm curious. Why?<br>
>> >><br>
>> >> Speed. I need a fast map of the 32-bit Float range to unsigned 32-bit<br>
>> >> integer range such that comparisons within the integer range are<br>
>> >> consistent with comparisons of their floats.<br>
>><br>
>> Ah, I can see how my wording created an ambiguous meaning..<br>
>><br>
>> > So am I right in thunking that you want that if the Float has an integer<br>
>> > equivalent the float and integer have the same hashKey32 and if they don't,<br>
>> > you don't care as long as the hash is well-distributed?<br>
>><br>
>> No I meant that I need to pickle Floats as an 32-bit Integer,<br>
><br>
><br>
> Now I'm really confused. How come you can get away with 32-bits when Floats<br>
> are 64-bits?<br>
<br>
</span>Because I need speed and efficiency more than precision. I'll be<br>
loading _billions_ of 64-bit Squeak Floats into a indexing system that<br>
operates on 32-bit integers (it can operate at any size even 256-bit<br>
but it operates much faster in a 32-bit range due to a lot smaller and<br>
fewer LargeIntegers and performance takes precedence).<br>
<span class=""><br>
>> but<br>
>> while in their pickled Integer state, I need to run #> and #<<br>
>> comparisons against other pickled Floats (e.g., as their Integer<br>
>> representation) and need those comparisons to produce the same results<br>
>> as if they were still in their Float state.<br>
>><br>
>> For example, the reason I cannot simply use asIEEE32Bit is because<br>
>> negative floats have a high-order bit set, and so the pickled<br>
>> represetnations don't compare correctly:<br>
>><br>
>> -4.321 asIEEE32Bit < 1.2345 asIEEE32Bit "false" <--- I need true<br>
><br>
><br>
> So you need an sign-insensitive absolute comparison? Easy to synthesize:<br>
><br>
> (self at: 1) bitAnd: 16r7FFFFFFF) << 32 + (self at: 2)<br>
<br>
</span>No, I need it to be sign-sensitive. That does not pass the example I<br>
gave. Here are the two number lines again from my original email. I<br>
need to map Floats from:<br>
<br>
-Infinity<-----------> +Infinity<br>
<br>
to Integers in the range:<br>
<br>
0<------------>((2^32)-1)<br>
<br>
-Infinity needs to map to 0 and +Infinity to (2^32)-1.<br>
<span class=""><br>
> This will put Infinity beyond the finite values.<br>
><br>
>><br>
>> 32-bit unsigned so I made -Infinity to be 0, +Infinity to be (2^32)-1.<br>
>> But since NaN needs representation too, I decided to put it at the<br>
>> top, so I bumped +Infinity down to (2^32)-2..<br>
><br>
><br>
> Again floats are 64-bit not 32-bit so I don't see how this can work.<br>
<br>
</span>Squeak Floats are 64-bit, but they can be easily converted to 32-bit<br>
floats for a loss in precision.<br>
<span class=""><br>
> If you<br>
> want something that orders things absolutely then something like this, which<br>
> is close to my immediate float representation will work. It effectively<br>
> rotates, putting the sign in the lsb:<br>
><br>
> | mostSignificantWord |<br>
> mostSignificantWord := self at: 1.<br>
> ^(mostSignificantWord bitAnd: 16r7FFFFFFF) << 33 + ((self at: 2) << 1)<br>
> + (mostSignificantWord >> 31)<br>
><br>
> This doesn't work for +/-0.0 since they have a zero exponent, but that's the<br>
> only exception<br>
<br>
</span>It benches to 18% faster than my range-checking but fails the example.<br>
<br>
-4.321 eliotHashKey32 < 1.2345 eliotHashKey32 "false" <--- I need true<br></blockquote><div><br></div><div>So you want the sign inverted then, right?</div><div><br></div><div><div style="color:rgb(0,0,0);font-size:13px"> | mostSignificantWord |</div><div style="color:rgb(0,0,0);font-size:13px"> mostSignificantWord := self at: 1.</div><div style="color:rgb(0,0,0);font-size:13px"> mostSignificantWord := mostSignificantWord bitXor: 16r80000000.<br></div><div style="color:rgb(0,0,0);font-size:13px"> ^mostSignificantWord << 32 + (self at: 2)</div></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
+/- 0.0 doesn't matter, I only need one 0.0.<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div class="gmail_signature">best,<div>Eliot</div></div>
</div></div>