summaryrefslogtreecommitdiff
path: root/boost/multiprecision/detail/generic_interconvert.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/multiprecision/detail/generic_interconvert.hpp')
-rw-r--r--boost/multiprecision/detail/generic_interconvert.hpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/boost/multiprecision/detail/generic_interconvert.hpp b/boost/multiprecision/detail/generic_interconvert.hpp
index e2d8487c87..ac3fe6640b 100644
--- a/boost/multiprecision/detail/generic_interconvert.hpp
+++ b/boost/multiprecision/detail/generic_interconvert.hpp
@@ -429,6 +429,13 @@ void generic_interconvert_float2rational(To& to, const From& from, const mpl::in
typename From::exponent_type e;
typename component_type<number<To> >::type num, denom;
number<From> val(from);
+
+ if (!val)
+ {
+ to = ui_type(0u);
+ return;
+ }
+
e = ilogb(val);
val = scalbn(val, -e);
while(val)