Changeset 26ebc6 in git for libpolys/coeffs/shortfl.cc


Ignore:
Timestamp:
Feb 25, 2013, 12:37:51 PM (10 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'ad2543eab51733612ba7d118afc77edca719600e')
Children:
27c79fcbc083eb57ec1345d22a6892cf162f017b
Parents:
0c516e37d47da9dbc827d68d2253f7289dfbfd3c8c2815d19daf34708c2cbc2cf44f8a95b28e3a28
Message:
Merge pull request #303 from YueRen/floatprint

chg: added brackets around floating numbers
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/shortfl.cc

    r0c516e r26ebc6  
    66* ABSTRACT:
    77*/
    8 #include <iostream>
    98#include <coeffs/shortfl.h>
    109
     
    249248  assume( getCoeffType(r) == ID );
    250249
    251   StringAppend("%9.3e", nf(a).F());
     250  char ch[11];
     251  int n = sprintf(ch,"%9.3e", nf(a).F());
     252  if (ch[0] == '-')
     253  {
     254    char* chbr = new char[n+3];
     255    memcpy(&chbr[2],&ch[1],n-1);
     256    chbr[0] = '-';
     257    chbr[1] = '(';
     258    chbr[n+1] = ')';
     259    chbr[n+2] = '\0';
     260    StringAppendS(chbr);
     261    delete chbr;
     262  }
     263  else
     264    StringAppend("(%s)",ch);
    252265}
    253266
     
    436449    signed long int exp;
    437450    basis = mpf_get_d_2exp(&exp, e);
    438     float f = ldexp(basis,exp);
     451    float f= mpf_sgn(e)*ldexp(basis,exp);
    439452    mpf_clear(e);
    440453    return nf(f).N();
     
    462475  signed long int exp;
    463476  basis = mpf_get_d_2exp(&exp, q);
    464   float f = ldexp(basis,exp);
     477  float f = mpf_sgn(e)*ldexp(basis,exp);
    465478  mpf_clear(e);
    466479  mpf_clear(d);
Note: See TracChangeset for help on using the changeset viewer.