Integer read/write ponderable

Integer read/write ponderable

Suppose you have an 5-digit integer variable and read into it the following:  03928

Immediately after the read, the variable appears to contain '3928'.

Later, this same variable is written out via format i5, and it appears as '_3928' (the leading zero has disappeared).

If the original value is replaced by '13028', it reads and writes exactly as expected, i.e., all 5 digits are preserved.

If I handled this as a character, I could manage this issue. But handling it as an integer, why does the compiler appear to swallow the leading zero in the 5-digit integer?  Is there an easy way to preserve it?

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Instead of i5 format use I5.5 which always outputs 5 digits padded with leading zero's

Thanks app4619.  I was thinking about ix.x - I've used this before for what I thought were other purposes.  It didn't dawn on me that it was applicable here.

Leave a Comment

Please sign in to add a comment. Not a member? Join today