@@ -563,43 +563,44 @@ Pure function.
563
563
564
564
- ` value ` : Shall be an ` integer/real/complex/logical ` scalar.
565
565
This is an ` intent(in) ` argument.
566
- - ` format ` : Shall be a ` character ` scalar like ` '(F6.2)' ` .
566
+ - ` format ` : Shall be a ` character(len=*) ` scalar like ` '(F6.2)' ` .
567
567
This is an ` intent(in) ` and ` optional ` argument.
568
568
569
569
#### Result value
570
570
571
- The result is an allocatable length ` character ` scalar with up to 128 cached ` character ` length.
571
+ The result is an ` allocatable ` length ` character ` scalar with up to ` 128 ` cached ` character ` length.
572
572
573
573
#### Example
574
574
575
575
``` fortran
576
576
program demo_to_string
577
- use :: stdlib_strings, only: to_string
577
+ use stdlib_strings, only: to_string
578
578
implicit none
579
579
580
- print *, 'to_string(complex) : '
581
- print *, to_string((1, 1)) ! (1.00000000,1.00000000)
582
- print *, to_string((1, 1), '(F6.2)') ! ( 1.00, 1.00)
583
- print *, to_string((1000, 1), '(ES0.2)'), to_string((1000, 1), '(SP,F6.3)') ! (1.00E+3,1.00)(******,+1.000)
584
- !! Too narrow formatter for real number
585
- !! Normal demonstration(`******` from Fortran Standard)
586
-
587
- print *, 'to_string(integer) : '
588
- print *, to_string(1) ! 1
589
- print *, to_string(1, '(I4)') ! 1
590
- print *, to_string(1, '(I0.4)'), to_string(2, '(B4)') ! 0001 10
591
-
592
- print *, 'to_string(real) : '
593
- print *, to_string(1.) ! 1.00000000
594
- print *, to_string(1., '(F6.2)') ! 1.00
595
- print *, to_string(1., '(SP,ES9.2)'), to_string(1, '(F7.3)') ! +1.00E+00[*]
596
- !! 1 wrong demonstration(`*` from `to_string`)
597
-
598
- print *, 'to_string(logical) : '
599
- print *, to_string(.true.) ! T
600
- print *, to_string(.true., '(L2)') ! T
601
- print *, to_string(.true., 'L2'), to_string(.false., '(I5)') ! [*][*]
602
- !! 2 wrong demonstrations(`*` from `to_string`)
580
+ !> Example for `complex` type
581
+ print *, to_string((1, 1)) !! "(1.00000000,1.00000000)"
582
+ print *, to_string((1, 1), '(F6.2)') !! "( 1.00, 1.00)"
583
+ print *, to_string((1000, 1), '(ES0.2)'), to_string((1000, 1), '(SP,F6.3)')
584
+ !! "(1.00E+3,1.00)""(******,+1.000)"
585
+ !! Too narrow formatter for real number
586
+ !! Normal demonstration(`******` from Fortran Standard)
587
+
588
+ !> Example for `integer` type
589
+ print *, to_string(-3) !! "-3"
590
+ print *, to_string(42, '(I4)') !! " 42"
591
+ print *, to_string(1, '(I0.4)'), to_string(2, '(B4)') !! "0001"" 10"
592
+
593
+ !> Example for `real` type
594
+ print *, to_string(1.) !! "1.00000000"
595
+ print *, to_string(1., '(F6.2)') !! " 1.00"
596
+ print *, to_string(1., '(SP,ES9.2)'), to_string(1, '(F7.3)') !! "+1.00E+00""[*]"
597
+ !! 1 wrong demonstration (`[*]` from `to_string`)
598
+
599
+ !> Example for `logical` type
600
+ print *, to_string(.true.) !! "T"
601
+ print *, to_string(.true., '(L2)') !! " T"
602
+ print *, to_string(.true., 'L2'), to_string(.false., '(I5)') !! "[*]""[*]"
603
+ !! 2 wrong demonstrations(`[*]` from `to_string`)
603
604
604
605
end program demo_to_string
605
606
```
0 commit comments