Kaydet (Commit) c24c32bf authored tarafından Stephan Bergmann's avatar Stephan Bergmann

ofz#4366 Divide-by-zero

Change-Id: I3d0eb3bb6a69d09e71ce8bf91051f66e204eb0df
Reviewed-on: https://gerrit.libreoffice.org/45098Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 54e14419
......@@ -34,6 +34,7 @@
#include <algorithm>
#include <cassert>
#include <float.h>
#include <limits>
#include <limits.h>
#include <math.h>
#include <stdlib.h>
......@@ -365,8 +366,15 @@ inline void doubleToString(typename T::String ** pResult,
int nExp = 0;
if ( fValue > 0.0 )
{
nExp = static_cast< int >(floor(log10(fValue)));
fValue /= getN10Exp(nExp);
// Cap nExp at a small value beyond which "fValue /= N10Exp" would lose precision (or N10Exp
// might even be zero); that will produce output with the decimal point in a non-normalized
// position, but the current quality of output for such small values is probably abysmal,
// anyway:
nExp = std::max(
static_cast< int >(floor(log10(fValue))), std::numeric_limits<double>::min_exponent10);
double const N10Exp = getN10Exp(nExp);
assert(N10Exp != 0);
fValue /= N10Exp;
}
switch (eFormat)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment