From 9504d804e05a10ee7bd6ad7185fad3bc00e00bf5 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sun, 25 Mar 2018 20:17:35 -0700 Subject: [PATCH] Stop using numeric_limits for the constant "255", and fix a bug. The bug is that `x % 255` is not quite the same thing as `x % 256`; but `x & 255` is. The stylistic issue is that `numeric_limits::max()` is a very verbose way of spelling `255`. --- code/vanity-miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/vanity-miner.cpp b/code/vanity-miner.cpp index 6c3ab412..277b4fea 100644 --- a/code/vanity-miner.cpp +++ b/code/vanity-miner.cpp @@ -45,7 +45,7 @@ bc::ec_secret random_secret(std::default_random_engine& engine) bc::ec_secret secret; // Iterate through every byte setting a random value... for (uint8_t& byte: secret) - byte = engine() % std::numeric_limits::max(); + byte = engine() & 255; // Return result. return secret; }