View previous topic :: View next topic |
Author |
Message |
SaintMichael57
Joined: 28 Nov 2016 Posts: 14
|
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 |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7938 Location: Salford, UK
|
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1895
|
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. |
|
Back to top |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2560 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. |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2391 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. |
|
Back to top |
|
|
|