Changeset 328

Show
Ignore:
Timestamp:
03/04/05 23:55:11 (4 years ago)
Author:
kris
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/mango/test/unittest.d

    r324 r328  
    24052405 
    24062406*******************************************************************************/ 
    2407 /+ 
     2407/+       
    24082408extern (C) 
    24092409{ 
    2410         double strtod (char *s00, char **se); 
    2411         char *dtoa    (double d, int mode, int ndigits, int *decpt, int *sign, char **rve); 
    2412  
    2413         void* __dToaMalloc (uint size) 
    2414         { 
    2415                 throw new Exception ("unhandled request from dtoa"); 
    2416                 return null; 
    2417         } 
    2418  
    24192410        int printf (char *format, ...) 
    24202411        { 
     
    24232414        } 
    24242415} 
    2425  
    2426 /******************************************************************************* 
    2427  
    2428  
    2429 *******************************************************************************/ 
     2416+/ 
     2417 
     2418/******************************************************************************* 
     2419 
     2420 
     2421*******************************************************************************/ 
     2422/+ 
     2423private import mango.format.DGDouble; 
    24302424 
    24312425void testConvert () 
     
    24352429        char *zz; 
    24362430        static uint[] ff = [1, 2, 3, 4]; 
    2437         char[] num = "0.30103010301030103001030103e-3"; 
     2431        char[] num = "0.12345678+1"; 
    24382432 
    24392433 
    24402434        double x = Double.parse (num); 
    24412435        double y = std.c.stdlib.strtold (num, &zz); 
    2442         double z = strtod (num, &zz); 
    2443  
    2444         char *end; 
    2445         int   dec, 
    2446               sign; 
    2447         char* ss = dtoa (x, 0, 20, &dec, &sign, &end); 
    2448  
     2436        double z = DGDouble.parse (num); 
     2437 
     2438         
    24492439        Stdout (Double.format (s, x, 20)) (CR); 
    24502440        Stdout (Double.format (s, y, 20)) (CR); 
     
    24532443        printf ("%.20lf\n", y); 
    24542444        printf ("%.20lf\n", z); 
    2455         printf ("%s\n", ss); 
     2445        printf ("%.*s\n", DGDouble.format (s, x, 4)); 
     2446        printf ("%.*s\n", DGDouble.format (s, z, 6, true, 0)); 
    24562447} 
    24572448+/