junegunn commented on code in PR #6558:
URL: https://github.com/apache/hbase/pull/6558#discussion_r1899164042


##########
hbase-diagnostics/src/main/java/org/apache/hadoop/hbase/PerformanceEvaluation.java:
##########
@@ -1205,7 +1205,7 @@ private static long nextRandomSeed() {
       this.opts = options;
       this.status = status;
       this.testName = this.getClass().getSimpleName();
-      everyN = (long) (opts.totalRows / (opts.totalRows * opts.sampleRate));
+      everyN = (long) (1 / opts.sampleRate);

Review Comment:
   AFAIK, we don't have to worry about it because 1.0 (1 / 2<sup>0</sup>) has a 
finite binary representation (unlike numbers like 0.1 or 0.2), so `(1 / 1.0)` 
will not yield any arithmetic error.
   
   ```
   irb(main):001> [0].pack('G').bytes.map { "%08b" % it }.join
   => "0000000000000000000000000000000000000000000000000000000000000000"
   irb(main):002> [1].pack('G').bytes.map { "%08b" % it }.join
   => "0011111111110000000000000000000000000000000000000000000000000000"
   irb(main):003> [0.1].pack('G').bytes.map { "%08b" % it }.join
   => "0011111110111001100110011001100110011001100110011001100110011010"
   irb(main):004> [0.2].pack('G').bytes.map { "%08b" % it }.join
   => "0011111111001001100110011001100110011001100110011001100110011010"
   ```
   
   
https://en.wikipedia.org/wiki/Double-precision_floating-point_format#Double-precision_examples



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to