Clicky

Fortran Wiki
strnum

Skip the Navigation Links | Home Page | All Pages | Recently Revised | Authors | Feeds | Export |
! Convert numeric values to strings and vice-versa using internal file IO
program strnum
 implicit none
 character(len=25) :: str
 real :: num
 ! Convert a numeric value to a string using an internal write
 num = 3.14
 write (str, '(g12.5)') num
 print *, 'str: ', str ! str: 3.1400
 ! Convert a string to a numeric value using an internal read
 str = '17.2'
 read (str, '(g12.5)') num
 print *, 'num: ', num ! num: 17.20000
end program strnum
Created on September 13, 2009 20:10:28 by Jason Blevins (75.178.9.182) (542 characters / 0.0 pages)
Edit | Views: Print | TeX | Source | Linked from: Code, 2009, FAQ

AltStyle によって変換されたページ (->オリジナル) /