From bdf19e26540cb8ccb9a7da2252d022ddef0ec80a Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 22 Mar 2011 21:34:04 +1100 Subject: [PATCH] nloop cleanup courtesy Serge Belyshev. --- main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index 2edd6d4..89b89ce 100644 --- a/main.c +++ b/main.c @@ -459,15 +459,17 @@ out: static i64 nloops(i64 seconds, uchar *b1, uchar *b2) { - i64 nloops_encoded, nloops; + i64 nloops; int nbits; nloops = ARBITRARY_AT_EPOCH * pow(MOORE_TIMES_PER_SECOND, seconds); - nbits = log (nloops) / M_LN2; - *b1 = nbits - 7; - *b2 = nloops >> *b1; - nloops_encoded = (i64)*b2 << (i64)*b1; - return nloops_encoded; + if (nloops < ARBITRARY) + nloops = ARBITRARY; + for (nbits = 0; nloops > 255; nbits ++) + nloops = nloops >> 1; + *b1 = nbits; + *b2 = nloops; + return nloops << nbits; } int main(int argc, char *argv[])