Skip to content

Commit af98964

Browse files
replacing float check with std::abs check
1 parent 01b3e41 commit af98964

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

src/Symbolic.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ void IR2Vec_Symbolic::generateSymbolicEncodings(std::ostream *o) {
6666
res += std::to_string(cls) + "\t";
6767

6868
for (auto i : pgmVector) {
69-
if ((i <= 0.0001 && i > 0) || (i < 0 && i >= -0.0001)) {
70-
i = 0;
71-
}
69+
if (std::abs(i) <= 1e-4f)
70+
i = 0.0f;
7271
res += std::to_string(i) + "\t";
7372
}
7473
res += "\n";

src/utils.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ std::string IR2Vec::updatedRes(IR2Vec::Vector &tmp, llvm::Function *f,
8585

8686
res += "=\t";
8787
for (auto i : tmp) {
88-
if ((i <= 0.0001 && i > 0) || (i < 0 && i >= -0.0001)) {
89-
i = 0;
90-
}
88+
if (std::abs(i) <= 1e-4f)
89+
i = 0.0f;
9190
res += std::to_string(i) + "\t";
9291
}
9392

0 commit comments

Comments
 (0)