Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to do Rounding a decimal part of number to 3 digit? 1

Status
Not open for further replies.

arunmd1

Programmer
Mar 20, 2008
24
0
0
FR
Hi

I need to round real numbers to 3 decimal places . There is no function round is available in FORTRAN . How to do it ?
 
It is called nint but that rounds to the nearest integer. If you want it to 3 decimal places for calculation, do something like
Code:
x = nint(x * 1000.0) * 1E-3
If you just want to print to 3DP but keep precision
Code:
print '(F10.3)', x
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top