Skip to content

Commit 70f92c0

Browse files
committed
Fixed printing of infinity in generated code
1 parent 0688213 commit 70f92c0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

include/taco/util/strings.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <map>
88
#include <iomanip>
99
#include <limits>
10+
#include <cmath>
1011

1112
// To get the value of a compiler macro variable
1213
#define STRINGIFY(x) #x
@@ -30,6 +31,9 @@ toString(const T &val) {
3031
template <class T>
3132
typename std::enable_if<std::is_floating_point<T>::value, std::string>::type
3233
toString(const T &val) {
34+
if (isinf(val)) {
35+
return (val < 0) ? "-INFINITY" : "INFINITY";
36+
}
3337
std::stringstream sstream;
3438
sstream << std::setprecision(std::numeric_limits<T>::max_digits10) << std::showpoint << val;
3539
return sstream.str();

0 commit comments

Comments
 (0)