Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Converting a string to decimal

4 views
Skip to first unread message

Mike Smith

unread,
Aug 4, 2015, 10:52:44 AM8/4/15
to
Hi Group,

Good to see the site problems have been resolved and the group is back
on-line again.

I am sure this is a simple problem but I have been messing with it for
hours.

CHARACTER FDS_SCRIPT*40

read( FDS_SCRIPT(6:), '(F10.4)' ) P_DEC

I am trying to convert part of the string FDS_SCRIPT to a decimal, the
content of FDS_SCRIPT is as follows:

1234 5

When using the read command to evaluation the number '5' I get a value of
0.0005 instead of 5

If the string is set to:

1234 5.1

Then the results computes correctly as 5.1 held by the variable P_DEC

Can you please assist, thank you.

Regards,

Mike

Marty Stanquist

unread,
Aug 4, 2015, 1:07:22 PM8/4/15
to
"Mike Smith" wrote in message news:mprc7t$kr2$1...@www.openwatcom.org...
The server isn't fully operational. But if you have a reply, go ahead and
post it. See the website for details.

Marty

Hans-Bernhard Bröker

unread,
Aug 4, 2015, 5:46:48 PM8/4/15
to
Am 04.08.2015 um 16:52 schrieb Mike Smith:

> read( FDS_SCRIPT(6:), '(F10.4)' ) P_DEC

> When using the read command to evaluation the number '5' I get a value
> of 0.0005 instead of 5

Well, that's the defined behaviour of a F format given with '.4', if the
input is missing the '.'. You should probably use '(F10.0)' instead, or
just plain '(F10)'. Look up the concept of "implied decimal point".


0 new messages