mahout-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Dunning <ted.dunn...@gmail.com>
Subject Re: Big Longs in RecommenderJob
Date Tue, 08 Jun 2010 15:32:49 GMT
I confess I don't quite understand the issue.  A comment or three might
help.

Does this line:

   return temp ^ ((raw >> 63) << 63);

Invert the sign bit if present in raw?

If so, would this be any different?

   return temp ^ (raw & (1<<63));


On Tue, Jun 8, 2010 at 4:42 AM, Sean Owen <srowen@gmail.com> wrote:

>  public static long readSignedVarLong(DataInput in) throws IOException {
>    long raw = readUnsignedVarLong(in);
>    return (((raw << 63) >> 63) ^ raw) >> 1;
>  }
>
> becomes
>
>  public static long readSignedVarLong(DataInput in) throws IOException {
>    long raw = readUnsignedVarLong(in);
>    long temp = (((raw << 63) >> 63) ^ raw) >> 1;
>    return temp ^ ((raw >> 63) << 63);
>  }
>
> and likewise for writing. It basically treats negative values as
> unsigned when asked to write unsigned and all is well.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message