summaryrefslogtreecommitdiff
path: root/wcon.c
diff options
context:
space:
mode:
authorJohn van Groningen2007-01-16 15:01:11 +0000
committerJohn van Groningen2007-01-16 15:01:11 +0000
commit94eda882ed9c68f67305c6fc663113c8c926f22f (patch)
treeb6478614592a0032b2383e8565a3b299dd456aa0 /wcon.c
parentstore number of values in xmm registers in rax before varargs c call of sprintf (diff)
fix printing of some values just below a power of 10,
print leading 0 for values >= 0.0001 and < 1.0
Diffstat (limited to 'wcon.c')
-rw-r--r--wcon.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/wcon.c b/wcon.c
index d48e1d5..15ac4df 100644
--- a/wcon.c
+++ b/wcon.c
@@ -1148,13 +1148,12 @@ char *convert_real_to_string (double d,char *s_p)
d *= scale_factor;
-#ifdef AI64
if (d<(1e14-0.5)){
-#else
- if (d<1e14){
-#endif
d *= 10.0;
--exponent;
+ } else if (d>=(1e15-0.5)){
+ d /= 10.0;
+ ++exponent;
}
#if 1
@@ -1216,19 +1215,20 @@ char *convert_real_to_string (double d,char *s_p)
*s_p++ = '0'+exponent_d10;
*s_p++ = '0'+exponent-10*exponent_d10;
} else {
- if (exponent>=-1){
+ if (exponent>=0){
for (n=-1; n>=exponent-(N_DIGITS-1); --n)
s_p[n+1]=s_p[n];
s_p[exponent-(N_DIGITS-1)]='.';
++s_p;
} else {
for (n=-1; n>=-N_DIGITS; --n)
- s_p[n-exponent]=s_p[n];
- s_p[-N_DIGITS] = '.';
-
+ s_p[1+n-exponent]=s_p[n];
+ s_p[1-N_DIGITS] = '.';
+ s_p[-N_DIGITS] = '0';
+
for (n=exponent; n<-1; ++n)
- s_p[-(N_DIGITS-1)+(n-exponent)] = '0';
- s_p+= -exponent;
+ s_p[1-(N_DIGITS-1)+(n-exponent)] = '0';
+ s_p+= 1-exponent;
}
while (s_p[-1]=='0')
@@ -1296,7 +1296,7 @@ void wait_for_key_press (VOID)
int free_memory (void *p)
{
#ifdef WINDOWS
- if (GlobalFree (p)==NULL)
+ if (LocalFree (p)==NULL)
return 0;
else
return GetLastError();