Suppress REALCVT for small whole real numbers.
This commit is contained in:
parent
19abce5535
commit
bd5d4c61c6
|
|
@ -22,10 +22,19 @@
|
|||
|
||||
#include "V3Error.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
|
||||
//============================================================================
|
||||
|
||||
// Return if two numbers within Epsilon of each other
|
||||
inline bool v3EpsilonEqual(double a, double b) {
|
||||
return fabs(a - b) <= (std::numeric_limits<double>::epsilon() * std::max(1.0, std::max(a, b)));
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
||||
class AstNode;
|
||||
|
||||
class V3Number {
|
||||
|
|
|
|||
|
|
@ -4342,9 +4342,12 @@ private:
|
|||
AstNRelinker linker;
|
||||
nodep->unlinkFrBack(&linker);
|
||||
if (AstConst* constp = VN_CAST(nodep, Const)) {
|
||||
// Ignore obvious conversions of whole real numbers, e.g. 1.0 -> 1
|
||||
// We convert to/from vlsint32 rather than use floor() as want to make sure is
|
||||
// representable in integer's number of bits
|
||||
if (constp->isDouble()
|
||||
&& constp->num().toDouble() == floor(constp->num().toDouble())) {
|
||||
&& v3EpsilonEqual(constp->num().toDouble(),
|
||||
static_cast<double>(
|
||||
static_cast<vlsint32_t>(constp->num().toDouble())))) {
|
||||
warnOn = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue