PDA

View Full Version : problem in setting decimal values


rkmaguluri
02-13-2004, 07:38 PM
hi,
i am using fortran 7.0 for .net
i declared a variable as Real and stored a value
ex:
Real x
x = 400.03
when i print x value as

write (*,*) x

it is printing the value as : 400.02999

but i want to set it for two decimal places only .

i am able to print with 2 decimal places using Format statement
but i want to store the value into the variable with 2 decimal places .
can u tell me how i can do that?

thank u
rkmaguluri

garyscott
02-16-2004, 08:10 PM
Hi,

You can't do that because there is no native data type with those internal characteristics. The best you can do is to convert it to the precision you need on printout:

write(*,'(f6.2)')x