use eo::log ; warning when returns 0
This commit is contained in:
parent
1ecf4d3def
commit
ce99bb02f1
1 changed files with 31 additions and 21 deletions
|
|
@ -4,6 +4,8 @@
|
||||||
// eoHowMany_h.h
|
// eoHowMany_h.h
|
||||||
// Base class for choosing a number of guys to apply something from a popsize
|
// Base class for choosing a number of guys to apply something from a popsize
|
||||||
// (c) Marc Schoenauer, 2000
|
// (c) Marc Schoenauer, 2000
|
||||||
|
// (c) Thales group, 2010 (Johann Dréo <johann.dreo@thalesgroup.com>)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
|
@ -66,6 +68,8 @@
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
#include <utils/eoLogger.h>
|
||||||
|
|
||||||
class eoHowMany : public eoPersistent
|
class eoHowMany : public eoPersistent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -90,7 +94,7 @@ public:
|
||||||
rate = 0.0; // just in case, but shoud be unused
|
rate = 0.0; // just in case, but shoud be unused
|
||||||
combien = int(_rate); // negative values are allowed here
|
combien = int(_rate); // negative values are allowed here
|
||||||
if (combien != _rate)
|
if (combien != _rate)
|
||||||
std::cerr << "Warning: Number was rounded in eoHowMany";
|
eo::log << eo::warnings << "Number was rounded in eoHowMany";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -115,7 +119,13 @@ public:
|
||||||
{
|
{
|
||||||
if (combien == 0)
|
if (combien == 0)
|
||||||
{
|
{
|
||||||
return (unsigned int) (rate * _size);
|
unsigned int res = static_cast<unsigned int>( std::ceil( rate * _size ) );
|
||||||
|
|
||||||
|
if( res == 0 ) {
|
||||||
|
eo::log << eo::warnings << "Call to a eoHowMany instance returns 0 (rate=" << rate << ", size=" << _size << ")" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
if (combien < 0)
|
if (combien < 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Reference in a new issue