summaryrefslogtreecommitdiff
path: root/zen/basic_math.h
diff options
context:
space:
mode:
Diffstat (limited to 'zen/basic_math.h')
-rw-r--r--zen/basic_math.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/zen/basic_math.h b/zen/basic_math.h
index 05d892ee..56cfd923 100644
--- a/zen/basic_math.h
+++ b/zen/basic_math.h
@@ -228,6 +228,8 @@ bool isNull(T value)
inline
int round(double d)
{
+ assert(d - 0.5 >= std::numeric_limits<int>::min() && //if double is larger than what int can represent:
+ d + 0.5 <= std::numeric_limits<int>::max()); //=> undefined behavior!
return static_cast<int>(d < 0 ? d - 0.5 : d + 0.5);
}
bgstack15