forums.silverfrost.com
Welcome to the Silverfrost forums

Author Message
Carl_Mesaros

Joined: 28 Nov 2016
Posts: 11

 Posted: Thu May 18, 2017 1:57 am    Post subject: formatting real numbers Dear Silverfrost Community: Is there a way to format real numbers to a significant number of decimal digits? I would like to use real numbers to two decimal numbers. It has to do with currency. Thank you. Best regards, Carl Mesaros
PaulLaidler

Joined: 21 Feb 2005
Posts: 5275
Location: Salford, UK

 Posted: Thu May 18, 2017 8:56 am    Post subject: You could use a standard Fortran specifier such as F6.2 or (when using FTN95) the FTN95 business editing features described in http://silverfrost.com/ftn95-help/exten/business_editing.aspx.
mecej4

Joined: 31 Oct 2006
Posts: 873

Posted: Fri May 19, 2017 12:31 am    Post subject: Re: formatting real numbers

 Carl_Mesaros wrote: I would like to use real numbers to two decimal numbers. It has to do with currency.

If you seek to implement fixed point real arithmetic with two digits after the decimal point, you will need to find a third-party package to do that. The intrinsic real types in Fortran are floating point types.
JohnCampbell

Joined: 16 Feb 2006
Posts: 1928
Location: Sydney

 Posted: Fri May 19, 2017 1:29 am    Post subject: If your question is about fixed precision arithmetic, you could use integer*8 cents as your accumulator. If your question is only about writing, then understand F10.2 or F0.2 formats. After that look at Paul's recommendation of business editing, which although non standard Fortran, provides very useful reporting.
LitusSaxonicum

Joined: 23 Aug 2005
Posts: 1771
Location: Yateley, Hants, UK

 Posted: Fri May 19, 2017 10:56 am    Post subject: I agree with John Campbell about using integers and computing money in cents, pence or whatever you use. Unless you are accounting for a very large corporation of a government, then you don't even need INTEGER*8 - INTEGER*4 will do.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT + 1 Hour Page 1 of 1