You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by GitBox <gi...@apache.org> on 2020/11/05 18:46:12 UTC

[GitHub] [incubator-datasketches-java] leerho commented on a change in pull request #332: Relative error quantiles

leerho commented on a change in pull request #332:
URL: https://github.com/apache/incubator-datasketches-java/pull/332#discussion_r518281624



##########
File path: src/main/java/org/apache/datasketches/Util.java
##########
@@ -380,6 +380,32 @@ public static boolean isMultipleOf8AndGT0(final long v) {
 
   //Powers of 2 related
 
+  /**
+   * Returns the number of one bits following the lowest-order ("rightmost") zero-bit in the
+   * two's complement binary representation of the specified long value, or 64 if the value is equal
+   * to minus one.
+   * @param v the value whose number of trailing ones is to be computed.
+   * @return the number of one bits following the lowest-order ("rightmost") zero-bit in the
+   * two's complement binary representation of the specified long value, or 64 if the value is equal
+   * to minus one.
+   */
+  public static int numberOfTrailingOnes(final long v) {
+    return Long.numberOfTrailingZeros(~v);
+  }
+
+  /**
+   * Returns the number of one bits preceding the highest-order ("leftmost") one-bit in the
+   * two's complement binary representation of the specified long value, or 64 if the value is equal
+   * to minus one.

Review comment:
       No.  Look at the Javadoc for java.lang.Long.numberOfTrailingZeros(long):
   "Returns the number of zero bits following the lowest-order ("rightmost") one-bit ...".  
   This is the complement of that, so the wording is:
   "Returns the number of one bits following the lowest-order ("rightmost") zero-bit ...".




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org