Subversion Repositories HelenOS-historic

Rev

Rev 276 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 276 Rev 323
Line 70... Line 70...
70
        intval2=fmath_fint(fmath_get_decimal_exponent(num),&intval);
70
        intval2=fmath_fint(fmath_get_decimal_exponent(num),&intval);
71
        exponent=intval;
71
        exponent=intval;
72
        if ((intval2<0.0)) exponent--;
72
        if ((intval2<0.0)) exponent--;
73
        num = num / ((fmath_dpow(10.0,exponent)));
73
        num = num / ((fmath_dpow(10.0,exponent)));
74
       
74
       
75
        print_double(num,modifier+1,precision); //modifier+1 = E => F or e => f
75
        print_double(num,modifier+1,precision); /* modifier+1 = E => F or e => f */
76
        putchar(modifier);
76
        putchar(modifier);
77
        if (exponent<0) {
77
        if (exponent<0) {
78
            putchar('-');
78
            putchar('-');
79
            exponent*=-1;
79
            exponent*=-1;
80
            }
80
        }
81
        print_number(exponent,10);
81
        print_number(exponent,10);
82
        return;
82
        return;
83
        }
83
    }
84
       
84
       
85
    //TODO: rounding constant - when we got fraction >= 0.5, we must increment last printed number 
85
    /* TODO: rounding constant - when we got fraction >= 0.5, we must increment last printed number */
86
 
86
 
-
 
87
    /*
87
    /* Here is problem with cumulative error while printing big double values -> we will divide
88
     * Here is a problem with cumulative error while printing big double values -> we will divide
88
    the number with a power of 10, print new number with better method for small numbers and then print decimal point at correct position */
89
     * the number with a power of 10, print new number with better method for small numbers and
-
 
90
     * then print decimal point at correct position.
-
 
91
     */
89
   
92
   
90
    fmath_fint(fmath_get_decimal_exponent(num),&intval);
93
    fmath_fint(fmath_get_decimal_exponent(num),&intval);
91
   
94
   
92
    exponent=(intval>0.0?intval:0);
95
    exponent=(intval>0.0?intval:0);
93
   
96
   
Line 133... Line 136...
133
    }
136
    }
134
   
137
   
135
    counter = (counter>=DEFAULT_DOUBLE_BUFFER_SIZE?DEFAULT_DOUBLE_BUFFER_SIZE:counter);
138
    counter = (counter>=DEFAULT_DOUBLE_BUFFER_SIZE?DEFAULT_DOUBLE_BUFFER_SIZE:counter);
136
    while (counter>0) {
139
    while (counter>0) {
137
        putchar(buf[--counter]);
140
        putchar(buf[--counter]);
138
    };
141
    }
139
    return;
142
    return;
140
}
143
}
141
 
144
 
142
/** Print NULL terminated string
145
/** Print NULL terminated string
143
 *
146
 *
Line 234... Line 237...
234
 *      digits).
237
 *      digits).
235
 * x    The next variant argument is treated as integer
238
 * x    The next variant argument is treated as integer
236
 *      and printed in standard hexadecimal format (only significant
239
 *      and printed in standard hexadecimal format (only significant
237
 *      digits).
240
 *      digits).
238
 * X    As with 'x', but '0x' is prefixed.
241
 * X    As with 'x', but '0x' is prefixed.
-
 
242
 * .    The decimal number following period will be treated as precision
-
 
243
 *      for printing floating point numbers. One of 'e', 'E', 'f' or 'F'
-
 
244
 *      must follow.
-
 
245
 * e    The next variant argument is treated as double precision float
-
 
246
 *      and printed in exponent notation with only one digit before decimal point
-
 
247
 *      in specified precision. The exponent sign is printed as 'e'.
-
 
248
 * E    As with 'e', but the exponent sign is printed as 'E'.
-
 
249
 * f    The next variant argument is treated as double precision float
-
 
250
 *      and printed in decimal notation in specified precision.
-
 
251
 * F    As with 'f'.
239
 *
252
 *
240
 * All other characters from fmt except the formatting directives
253
 * All other characters from fmt except the formatting directives
241
 * are printed in verbatim.
254
 * are printed in verbatim.
242
 *
255
 *
243
 * @param fmt Formatting NULL terminated string.
256
 * @param fmt Formatting NULL terminated string.
Line 257... Line 270...
257
    spinlock_lock(&printflock);
270
    spinlock_lock(&printflock);
258
 
271
 
259
    while (c = fmt[i++]) {
272
    while (c = fmt[i++]) {
260
        switch (c) {
273
        switch (c) {
261
 
274
 
262
           
-
 
263
           
-
 
264
            /* control character */
275
            /* control character */
265
            case '%':
276
            case '%':
266
           
-
 
267
                precision = DEFAULT_DOUBLE_PRECISION;
277
            precision = DEFAULT_DOUBLE_PRECISION;
268
                if (fmt[i]=='.') {
278
            if (fmt[i]=='.') {
269
                    precision=0;
279
                precision=0;
270
                    c=fmt[++i];
280
                c=fmt[++i];
271
                        while((c>='0')&&(c<='9')) {
281
                while((c>='0')&&(c<='9')) {
272
                            precision = precision*10 + c - '0';
282
                    precision = precision*10 + c - '0';
273
                            c=fmt[++i];
283
                    c=fmt[++i];
274
                            }
284
                }
275
                       
-
 
276
                }
285
            }
277
           
286
           
278
                switch (c = fmt[i++]) {
287
            switch (c = fmt[i++]) {
279
 
288
 
280
                /* percentile itself */
289
                /* percentile itself */
Line 326... Line 335...
326
                    goto loop;
335
                goto loop;
327
 
336
 
328
                /*
337
                /*
329
                         * Floating point conversions.
338
                     * Floating point conversions.
330
                         */
339
                     */
331
               
-
 
332
                case 'F':
340
                case 'F':
333
                        print_double(va_arg(ap, double),'F',precision);
341
                    print_double(va_arg(ap, double),'F',precision);
334
                    goto loop;
342
                goto loop;
335
                   
343
                   
336
                case 'f':
344
                case 'f':