Molecular Modeling Software
リビジョン | 610210450aec7eea9ee86f6b45004826c25e0945 (tree) |
---|---|
日時 | 2016-09-09 09:48:46 |
作者 | toshinagata1964 <toshinagata1964@a2be...> |
コミッター | toshinagata1964 |
Creating cube file failed when very small electron density (<1e-100) appeared. Fixed.
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/molby/trunk@606 a2be9bc6-48de-4e38-9406-05402d4bc13c
@@ -11658,8 +11658,15 @@ MoleculeOutputCube(Molecule *mp, Int index, const char *fname, const char *comme | ||
11658 | 11658 | /* On Windows, the "%e" format writes the exponent in 3 digits, but |
11659 | 11659 | this is not standard. So we avoid using %e */ |
11660 | 11660 | Double d = cp->dp[n++]; |
11661 | - int exponent = (int)floor(log10(fabs(d))); | |
11662 | - Double base = d * pow(10, -1.0 * exponent); | |
11661 | + int exponent; | |
11662 | + Double base; | |
11663 | + if (d >= -1.0e-90 && d <= 1.0e-90) { | |
11664 | + exponent = 0; | |
11665 | + base = 0.0; | |
11666 | + } else { | |
11667 | + exponent = (int)floor(log10(fabs(d))); | |
11668 | + base = d * pow(10, -1.0 * exponent); | |
11669 | + } | |
11663 | 11670 | fprintf(fp, " %8.5fe%+03d", base, exponent); |
11664 | 11671 | /* fprintf(fp, " %12.5e", d); */ |
11665 | 11672 | if (k == cp->nz - 1 || k % 6 == 5) |