Skip to content

Commit 0b81872

Browse files
committed
Added docs for formatting constants.
1 parent 859e630 commit 0b81872

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

doc/specs/stdlib_io.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,44 @@ program demo_getline
273273
end do
274274
end program demo_getline
275275
```
276+
277+
## Formatting constants
278+
279+
### Status
280+
281+
Experimental
282+
283+
### Description
284+
285+
Formatting constants for printing out integer, floating point, and complex numbers at their full precision.
286+
Provides formats for all kinds as defined in stdlib_kinds
287+
288+
### Example
289+
290+
```fortran
291+
program deom_fmt_constants
292+
use intrinsic, iso_fortran_env, only : int32, int64, float32, float64
293+
use stdlib_io, only : FMT_INT, FMT_REAL_SP, FMT_REAL_DP, FMT_COMPLEX_SP, FMT_COMPLEX_DP
294+
implicit none
295+
296+
integer(kind=int32) :: i32
297+
integer(kind=int64) :: i64
298+
real(kind=real32) :: r32
299+
real(kind=real64) :: r64
300+
complex(kind=real32) :: c32
301+
complex(kind=real64) :: c64
302+
303+
i32 = 100_int32
304+
i64 = 100_int64
305+
r32 = 100.0_real32
306+
r64 = 100.0_real64
307+
c32 = cmplx(100.0_real32, kind=real32)
308+
c64 = cmplx(100.0_real64, kind=real64)
309+
310+
print FMT_INT, i32, i64
311+
print FMT_REAL_SP, r32
312+
print FMT_REAL_DP, r64
313+
print FMT_COMPLEX_SP, c32
314+
print FMT_COMPLEX_DP, c64
315+
316+
```

0 commit comments

Comments
 (0)