summaryrefslogtreecommitdiff
path: root/src/set_d64.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2012-09-04 09:08:59 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2012-09-04 09:08:59 +0000
commit45850d13610033dc93dd64cbe860cdbe20333bd8 (patch)
tree10962da5620e28aad2980a360b19985c39005633 /src/set_d64.c
parentb8f1339ef3c8635ea3925dbc0348de5e765b13f4 (diff)
downloadmpfr-45850d13610033dc93dd64cbe860cdbe20333bd8.tar.gz
[src/set_d64.c] better code to detect -0.0 (copied from set_d.c)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@8407 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/set_d64.c')
-rw-r--r--src/set_d64.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/set_d64.c b/src/set_d64.c
index aa4b47a33..5d52763aa 100644
--- a/src/set_d64.c
+++ b/src/set_d64.c
@@ -224,7 +224,6 @@ decimal64_to_string (char *s, _Decimal64 d)
{
int sign = 0, n;
int exp = 0;
- char *s0 = s;
if (d != d) /* NaN */
{
@@ -244,13 +243,21 @@ decimal64_to_string (char *s, _Decimal64 d)
/* now d is neither NaN nor +Inf nor -Inf */
- /* warning: we cannot distinguish -0.0 from +0.0 */
- if (d < (_Decimal64) 0.0 || (d == (_Decimal64) -0.0 &&
- (_Decimal64) 1.0 / d < (_Decimal64) 0.0))
+ if (d < (_Decimal64) 0.0)
{
sign = 1;
d = -d;
}
+ else if (d == (_Decimal64) -0.0)
+ { /* warning: the comparison d == -0.0 returns true for d = 0.0 too,
+ copy code from set_d.c here */
+ double dd = (double) d, negzero = DBL_NEG_ZERO;
+ if (memcmp (&dd, &negzero, sizeof(double)) == 0)
+ {
+ sign = 1;
+ d = -d;
+ }
+ }
/* now normalize d in [0.1, 1[ */
if (d >= (_Decimal64) 1.0)