forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

formatting real numbers

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Carl_Mesaros



Joined: 28 Nov 2016
Posts: 6

PostPosted: Thu May 18, 2017 1:57 am    Post subject: formatting real numbers Reply with quote

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. Smile


Best regards,
Carl Mesaros
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Thu May 18, 2017 8:56 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 732

PostPosted: Fri May 19, 2017 12:31 am    Post subject: Re: formatting real numbers Reply with quote

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
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 1774
Location: Sydney

PostPosted: Fri May 19, 2017 1:29 am    Post subject: Reply with quote

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
View user's profile Send private message
LitusSaxonicum



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

PostPosted: Fri May 19, 2017 10:56 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group