Silverfrost Forums

Welcome to our forums

formatting real numbers

18 May 2017 12:57 #19641

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
18 May 2017 7:56 #19642

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.

18 May 2017 11:31 #19645

Quoted from Carl_Mesaros 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.

19 May 2017 12:29 #19647

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.

19 May 2017 9:56 #19649

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 INTEGER8 - INTEGER4 will do.

Please login to reply.