about summary refs log tree commit diff
path: root/absl/random/log_uniform_int_distribution.h
diff options
context:
space:
mode:
Diffstat (limited to 'absl/random/log_uniform_int_distribution.h')
-rw-r--r--absl/random/log_uniform_int_distribution.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/absl/random/log_uniform_int_distribution.h b/absl/random/log_uniform_int_distribution.h
index 956a69070ccd..de58bdbe14ca 100644
--- a/absl/random/log_uniform_int_distribution.h
+++ b/absl/random/log_uniform_int_distribution.h
@@ -192,13 +192,15 @@ log_uniform_int_distribution<IntType>::Generate(
     const double r = std::pow(p.base(), d);
     const double s = (r * p.base()) - 1.0;
 
-    base_e = (r > (std::numeric_limits<unsigned_type>::max)())
-                 ? (std::numeric_limits<unsigned_type>::max)()
-                 : static_cast<unsigned_type>(r);
-
-    top_e = (s > (std::numeric_limits<unsigned_type>::max)())
-                ? (std::numeric_limits<unsigned_type>::max)()
-                : static_cast<unsigned_type>(s);
+    base_e =
+        (r > static_cast<double>((std::numeric_limits<unsigned_type>::max)()))
+            ? (std::numeric_limits<unsigned_type>::max)()
+            : static_cast<unsigned_type>(r);
+
+    top_e =
+        (s > static_cast<double>((std::numeric_limits<unsigned_type>::max)()))
+            ? (std::numeric_limits<unsigned_type>::max)()
+            : static_cast<unsigned_type>(s);
   }
 
   const unsigned_type lo = (base_e >= p.range()) ? p.range() : base_e;