mirror of
https://github.com/reactos/reactos.git
synced 2025-06-06 18:00:41 +00:00
Geoffroy Couprie <geo DOT couprie AT gmail DOT com>:
- Fix a printf case, where the exponent is zero - Implement exponent increment/decrement for printf in scientific notation My changes <grschneider AT gmail DOT com>: - Change some lessequal/greaterequal to equal - Exchange OR with AND operation - Modify patch identation to match current code, remove FIXME - Skipped the ecvt part of the patch (not needed, sprint has the bugs) - Fixes five msvcrt printf winetests, see bug #4584 for more information svn path=/trunk/; revision=41799
This commit is contained in:
parent
552a269ce8
commit
e80cf32fd5
1 changed files with 25 additions and 10 deletions
|
@ -168,7 +168,7 @@ numberf(char * buf, char * end, double num, char exp_sign, int size, int precisi
|
||||||
int ro = 0;
|
int ro = 0;
|
||||||
int isize;
|
int isize;
|
||||||
|
|
||||||
double frac, intr;
|
double num2, frac, intr;
|
||||||
double p;
|
double p;
|
||||||
|
|
||||||
char c, sign, digits[66];
|
char c, sign, digits[66];
|
||||||
|
@ -185,7 +185,12 @@ numberf(char * buf, char * end, double num, char exp_sign, int size, int precisi
|
||||||
if ( exp_sign == 'g' || exp_sign == 'G' || exp_sign == 'e' || exp_sign == 'E' )
|
if ( exp_sign == 'g' || exp_sign == 'G' || exp_sign == 'e' || exp_sign == 'E' )
|
||||||
{
|
{
|
||||||
ie = ((unsigned int)n.n->exponent - (unsigned int)0x3ff);
|
ie = ((unsigned int)n.n->exponent - (unsigned int)0x3ff);
|
||||||
exponent = ie/3.321928;
|
if (*n.__n == 0.0)
|
||||||
|
exponent = 0.0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
exponent = ie/3.321928;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( exp_sign == 'g' || exp_sign == 'G' )
|
if ( exp_sign == 'g' || exp_sign == 'G' )
|
||||||
|
@ -201,17 +206,27 @@ numberf(char * buf, char * end, double num, char exp_sign, int size, int precisi
|
||||||
if ( exp_sign == 'e' || exp_sign == 'E' )
|
if ( exp_sign == 'e' || exp_sign == 'E' )
|
||||||
{
|
{
|
||||||
frac = modf(exponent,&e);
|
frac = modf(exponent,&e);
|
||||||
/* FIXME: this exponent over-/underflow scheme doesn't comply with the wanted behaviour
|
if (num < 0.0)
|
||||||
* needed at all or completely different in original? */
|
|
||||||
#if 0
|
|
||||||
if ( frac > 0.5 )
|
|
||||||
e++;
|
|
||||||
else if ( frac < -0.5 )
|
|
||||||
e--;
|
e--;
|
||||||
#endif
|
if (frac >= 0.5)
|
||||||
|
e++;
|
||||||
|
else if (frac < -0.5)
|
||||||
|
e--;
|
||||||
|
|
||||||
|
num2 = num/pow(10.0L,(long double)e);
|
||||||
|
if (num2 < 1.0 && num2 > -1.0)
|
||||||
|
{
|
||||||
|
e--;
|
||||||
|
num2 = num/pow(10.0L,(long double)e);
|
||||||
|
}
|
||||||
|
else if (num2 < -10.0 && num2 > 10.0)
|
||||||
|
{
|
||||||
|
e++;
|
||||||
|
num2 = num/pow(10.0L,(long double)e);
|
||||||
|
}
|
||||||
|
|
||||||
/* size-5 because "e+abc" is going to follow */
|
/* size-5 because "e+abc" is going to follow */
|
||||||
buf = numberf(buf, end, num/pow(10.0L,(long double)e), 'f', size-5, precision, type);
|
buf = numberf(buf, end, num2, 'f', size-5, precision, type);
|
||||||
isize = 4;
|
isize = 4;
|
||||||
while(*(buf-1) == ' ')
|
while(*(buf-1) == ' ')
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue