Skip to content

Commit

Permalink
Fix sume numeric cast errors
Browse files Browse the repository at this point in the history
  • Loading branch information
antialize committed Mar 30, 2012
1 parent 8bbccfd commit a8e9ef6
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions tpie/execution_time_predictor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,14 @@ TPIE_OS_OFFSET execution_time_predictor::end_execution() {

std::string execution_time_predictor::estimate_remaining_time(double progress) {
double time = static_cast<double>((boost::posix_time::microsec_clock::local_time()-m_start_time).total_milliseconds());
time -= (s_pause_time - m_pause_time_at_start);
time -= static_cast<double>(s_pause_time - m_pause_time_at_start);

double a = m_confidence * (1.0 - progress);
double b = (1.0-m_confidence) * (1.0 - progress) + progress;

double t2 = (progress < 0.00001)?0:time/progress;
if (m_confidence * a + progress * b < 0.2) return "Estimating";
double estimate = m_estimate * a + t2 * b;
double estimate = static_cast<double>(m_estimate) * a + t2 * b;

double remaining = estimate * (1.0-progress);

Expand Down
4 changes: 1 addition & 3 deletions tpie/fractional_progress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,9 @@ fractional_subindicator::~fractional_subindicator() {
}

fractional_progress::fractional_progress(progress_indicator_base * pi):
m_pi(pi), m_add_state(true),
#ifndef TPIE_NDEBUG
m_init_called(false),
#endif
m_pi(pi), m_add_state(true),
#ifndef TPIE_NDEBUG
m_done_called(false),
#endif
m_confidence(1.0), m_total_sum(0), m_time_sum(0), m_timed_sum(0) {}
Expand Down
4 changes: 2 additions & 2 deletions tpie/hash_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ class chaining_hash_table {
first_free = 0;
for (size_t i=0; i < buckets.size(); ++i) {
buckets[i].value = unused;
buckets[i].next = i+1;
buckets[i].next = static_cast<index_t>(i+1);
}
for (typename array<index_t>::iterator i=list.begin(); i != list.end(); ++i)
*i = std::numeric_limits<index_t>::max();
}

void resize(size_t z) {
buckets.resize(z);
size_t x=size_t(99+z*sc)|1;
size_t x=static_cast<size_t>(99+static_cast<double>(z)*sc)|1;
while (!is_prime(x)) x -= 2;
list.resize(x);
clear();
Expand Down
2 changes: 1 addition & 1 deletion tpie/logstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void log_stream_buf::flush() {

int log_stream_buf::overflow(int c) {
flush();
*pptr() = c;
*pptr() = static_cast<char>(c);
pbump(1);
return c;
}
Expand Down
3 changes: 2 additions & 1 deletion tpie/progress_indicator_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ class progress_indicator_base {
#endif
if (m_current > m_next) {
ticks currentTicks = getticks();
m_next = static_cast<TPIE_OS_OFFSET>(m_current * (elapsed(currentTicks, m_start) + m_threshold)/
m_next = static_cast<TPIE_OS_OFFSET>(
static_cast<double>(m_current) * (elapsed(currentTicks, m_start) + m_threshold)/
elapsed(currentTicks, m_start));
refresh();
}
Expand Down

0 comments on commit a8e9ef6

Please sign in to comment.