From: Stephen Morris Date: Thu, 26 Feb 2015 15:51:28 +0000 (+0000) Subject: [3729] Fix problem of unintentional integer division X-Git-Tag: trac3745_base~4^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eb33abc55fd23e2e68d4e8f983398417d5a344a3;p=thirdparty%2Fkea.git [3729] Fix problem of unintentional integer division --- diff --git a/src/bin/perfdhcp/rate_control.cc b/src/bin/perfdhcp/rate_control.cc index 1c2a6004fe..8e2a90ef37 100644 --- a/src/bin/perfdhcp/rate_control.cc +++ b/src/bin/perfdhcp/rate_control.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013, 2015 Internet Systems Consortium, Inc. ("ISC") // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above @@ -51,15 +51,16 @@ RateControl::getOutboundMessageCount() { // Reset number of exchanges. uint64_t due_exchanges = 0; // If rate is specified from the command line we have to - // synchornize with it. + // synchronize with it. if (getRate() != 0) { time_period period(send_due_, now); time_duration duration = period.length(); // due_factor indicates the number of seconds that // sending next chunk of packets will take. - double due_factor = duration.fractional_seconds() / - time_duration::ticks_per_second(); - due_factor += duration.total_seconds(); + double due_factor = + static_cast(duration.fractional_seconds()) / + static_cast(time_duration::ticks_per_second()); + due_factor += static_cast(duration.total_seconds()); // Multiplying due_factor by expected rate gives the number // of exchanges to be initiated. due_exchanges = static_cast(due_factor * getRate());