The R Project SVN R

Rev

Rev 24331 | Rev 30822 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 24331 Rev 25249
Line 1... Line 1...
1
 
1
 
2
R : Copyright 2003, The R Development Core Team
2
R : Copyright 2003, The R Development Core Team
3
Version 1.7.0 Patched (2003-05-15)
3
Version 1.7.1 Patched (2003-07-18)
4
 
4
 
5
R is free software and comes with ABSOLUTELY NO WARRANTY.
5
R is free software and comes with ABSOLUTELY NO WARRANTY.
6
You are welcome to redistribute it under certain conditions.
6
You are welcome to redistribute it under certain conditions.
7
Type `license()' or `licence()' for distribution details.
7
Type `license()' or `licence()' for distribution details.
8
 
8
 
Line 456... Line 456...
456
 3rd Qu.: 47.55   3rd Qu.:0.21925  
456
 3rd Qu.: 47.55   3rd Qu.:0.21925  
457
 Max.   :370.00   Max.   :0.81000  
457
 Max.   :370.00   Max.   :0.81000  
458
                                   
458
                                   
459
> ## in 1.7.0, things were split to more lines
459
> ## in 1.7.0, things were split to more lines
460
> 
460
> 
-
 
461
> ## format.default(*, nsmall > 0)  -- for real and complex
-
 
462
> 
-
 
463
> sf <- function(x, N=14) sapply(0:N, function(i) format(x,nsmall=i))
-
 
464
> sf(2)
-
 
465
 [1] "2"                "2.0"              "2.00"             "2.000"           
-
 
466
 [5] "2.0000"           "2.00000"          "2.000000"         "2.0000000"       
-
 
467
 [9] "2.00000000"       "2.000000000"      "2.0000000000"     "2.00000000000"   
-
 
468
[13] "2.000000000000"   "2.0000000000000"  "2.00000000000000"
-
 
469
> sf(3.141)
-
 
470
 [1] "3.141"            "3.141"            "3.141"            "3.141"           
-
 
471
 [5] "3.1410"           "3.14100"          "3.141000"         "3.1410000"       
-
 
472
 [9] "3.14100000"       "3.141000000"      "3.1410000000"     "3.14100000000"   
-
 
473
[13] "3.141000000000"   "3.1410000000000"  "3.14100000000000"
-
 
474
> sf(-1.25, 20)
-
 
475
 [1] "-1.25"                   "-1.25"                   "-1.25"                  
-
 
476
 [4] "-1.250"                  "-1.2500"                 "-1.25000"               
-
 
477
 [7] "-1.250000"               "-1.2500000"              "-1.25000000"            
-
 
478
[10] "-1.250000000"            "-1.2500000000"           "-1.25000000000"         
-
 
479
[13] "-1.250000000000"         "-1.2500000000000"        "-1.25000000000000"      
-
 
480
[16] "-1.250000000000000"      "-1.2500000000000000"     "-1.25000000000000000"   
-
 
481
[19] "-1.250000000000000000"   "-1.2500000000000000000"  "-1.25000000000000000000"
-
 
482
> 
-
 
483
> oDig <- options(digits= 3)
-
 
484
> sf(pi)
-
 
485
 [1] "3.14"             "3.14"             "3.14"             "3.142"           
-
 
486
 [5] "3.1416"           "3.14159"          "3.141593"         "3.1415927"       
-
 
487
 [9] "3.14159265"       "3.141592654"      "3.1415926536"     "3.14159265359"   
-
 
488
[13] "3.141592653590"   "3.1415926535898"  "3.14159265358979"
-
 
489
> sf(1.2e7)
-
 
490
 [1] "1.2e+07" "1.2e+07" "1.2e+07" "1.2e+07" "1.2e+07" "1.2e+07" "1.2e+07"
-
 
491
 [8] "1.2e+07" "1.2e+07" "1.2e+07" "1.2e+07" "1.2e+07" "1.2e+07" "1.2e+07"
-
 
492
[15] "1.2e+07"
-
 
493
> sf(1.23e7)
-
 
494
 [1] "12300000"                "12300000.0"              "12300000.00"            
-
 
495
 [4] "12300000.000"            "12300000.0000"           "12300000.00000"         
-
 
496
 [7] "12300000.000000"         "12300000.0000000"        "12300000.00000000"      
-
 
497
[10] "12300000.000000000"      "12300000.0000000000"     "12300000.00000000000"   
-
 
498
[13] "12300000.000000000000"   "12300000.0000000000000"  "12300000.00000000000000"
-
 
499
> s <- -0.01234
-
 
500
> sf(s)
-
 
501
 [1] "-0.0123"           "-0.0123"           "-0.0123"          
-
 
502
 [4] "-0.0123"           "-0.0123"           "-0.01234"         
-
 
503
 [7] "-0.012340"         "-0.0123400"        "-0.01234000"      
-
 
504
[10] "-0.012340000"      "-0.0123400000"     "-0.01234000000"   
-
 
505
[13] "-0.012340000000"   "-0.0123400000000"  "-0.01234000000000"
-
 
506
> 
-
 
507
> sf(pi + 2.2i)
-
 
508
 [1] "3.14+2.2i"                          "3.14+2.2i"                         
-
 
509
 [3] "3.14+2.20i"                         "3.142+2.200i"                      
-
 
510
 [5] "3.1416+2.2000i"                     "3.14159+2.20000i"                  
-
 
511
 [7] "3.141593+2.200000i"                 "3.1415927+2.2000000i"              
-
 
512
 [9] "3.14159265+2.20000000i"             "3.141592654+2.200000000i"          
-
 
513
[11] "3.1415926536+2.2000000000i"         "3.14159265359+2.20000000000i"      
-
 
514
[13] "3.141592653590+2.200000000000i"     "3.1415926535898+2.2000000000000i"  
-
 
515
[15] "3.14159265358979+2.20000000000000i"
-
 
516
> sf(s + pi*1i)
-
 
517
 [1] "-0.0123+3.14i"                        "-0.0123+3.14i"                       
-
 
518
 [3] "-0.0123+3.14i"                        "-0.0123+ 3.142i"                     
-
 
519
 [5] "-0.0123+ 3.1416i"                     "-0.01234+ 3.14159i"                  
-
 
520
 [7] "-0.012340+ 3.141593i"                 "-0.0123400+ 3.1415927i"              
-
 
521
 [9] "-0.01234000+ 3.14159265i"             "-0.012340000+ 3.141592654i"          
-
 
522
[11] "-0.0123400000+ 3.1415926536i"         "-0.01234000000+ 3.14159265359i"      
-
 
523
[13] "-0.012340000000+ 3.141592653590i"     "-0.0123400000000+ 3.1415926535898i"  
-
 
524
[15] "-0.01234000000000+ 3.14159265358979i"
-
 
525
> 
-
 
526
> options(oDig)
-
 
527
>