- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a problem with the READ statement. Here it is.
If INCARD is '3 ', ASURCH will be '3 ' thru the READ statement below.
CHARACTER*3 INCHARD
INCARD = '3 '
READ (INCARD, 100, ERR=9000) ASURCH
100 FORMAT (BZ, A3)
Later, if I make another READ statement below to make ASURCH into a REAL number (F3.2), I will not get '3.0' but '0.02999999' instead. Why?
READ(ASURCH, 130) SURCHR130 FORMAT(F3.2)
Please help.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You're getting .03 read in. Since there's no BZ in the 130 format, the default is BN and blanks are ignored. So you effectively have 'bb3' (where b is blank) and a F3.2 reads that as .03. By the way, BZ is meaningless for an A format.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
'BZ' was the problem. Thanks for the help.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page