For Programmers: Free Programming Magazines  


Home > Archive > Fortran > July 2004 > Fortran and financial calculations









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Fortran and financial calculations
Gastfreund aus Korinth

2004-07-28, 9:06 pm

Is Fortran 95 suitable for financial calculations? I mean: I probably have
to perform all calculations with two digits after the decimal point and
then do some "Banker's rounding", but I have really no idea.

TIA,
GaK
Klaus Wacker

2004-07-28, 9:06 pm

Gastfreund aus Korinth <keine@nirgendwo.de> wrote:
> Is Fortran 95 suitable for financial calculations? I mean: I probably have
> to perform all calculations with two digits after the decimal point and
> then do some "Banker's rounding", but I have really no idea.
>


One common trick is to perform all calculations in Cents (or Lepta or
whatever) and then shift the decimal point just for printing EURO (or
$ or EYPO or whatever) amounts. This at least avoids the problem that
a number like 0.01 EUR does not have an exact representation in binary
floating point. Double precision variables hold more digits than
integers and they may give you a handle for rounding.

Rounding may be more tricky. Whatever "Banker's rounding" means, you
will probably have to implement it by hand using AINT, ANINT or
whatever is suitable. The real problem is to avoid intermediate
rounding in more complex calculations (more complex than a single
operation).


--
Klaus Wacker wacker@Physik.Uni-Dortmund.DE
Experimentelle Physik V http://www.physik.uni-dortmund.de/~wacker
Universitaet Dortmund Tel.: +49 231 755 3587
D-44221 Dortmund Fax: +49 231 755 4547
David Frank

2004-07-28, 9:06 pm


"Gastfreund aus Korinth" <keine@nirgendwo.de> wrote in message
news:pan.2004.07.27.05.53.48.109000@nirgendwo.de...
> Is Fortran 95 suitable for financial calculations? I mean: I probably have
> to perform all calculations with two digits after the decimal point and
> then do some "Banker's rounding", but I have really no idea.
>
> TIA,
> GaK
>



Earlier this year I showed a Fortran solution
http://home.cfl.rr.com/davegemini/decimal.f90

to a multi-language challenge called "The IBM Telco Benchmark"
that has fastest processing of the 1 million phone call file.

Review: http://www2.hursley.ibm.com/decimal/telco.html






Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com