@@ -563,43 +563,44 @@ Pure function.
563563
564564- ` value ` : Shall be an ` integer/real/complex/logical ` scalar.
565565 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)' ` .
567567 This is an ` intent(in) ` and ` optional ` argument.
568568
569569#### Result value
570570
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.
572572
573573#### Example
574574
575575``` fortran
576576program demo_to_string
577- use :: stdlib_strings, only: to_string
577+ use stdlib_strings, only: to_string
578578 implicit none
579579
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`)
603604
604605end program demo_to_string
605606```
0 commit comments