Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rational Numbers in C#

Status
Not open for further replies.

Miceal

Programmer
Feb 1, 2002
3
GB
I am writing an assembly that will be used in a suite of financial applcations. Naturally I must use integer arithmetic to ensure the accuracy of my calculations and in the past [in c++] have used the rational number class from the Boost libararies. Is there anything out there like that or for that matter in the framework that I am missing.

Cheers

Mike
 
I am not sure if there is something similar to CURRENCY and COleCurrency data types.
If you need rounding and calculation accuracy a solution is to write a class that
deals with money. Derive a class from COleCurrency which is useful for calculations involving money, or for any fixed-point calculation where accuracy is particularly important
and implemented methods to manage the precision, rounding , fixed-point calculation.
Use GetLocaleInfo(.,LOCALE_SCURRENCY,. ) to retrieve currency info from the regional settings and format (abbreviation, name, symbol...) currency values.
Put evrything in a .dll and refer it across projects or in a C# project.

In native C# use Single or Double data types to encapsulate in one class money calculation (precision, rounding, fixed-point).
To format the currency values use CultureInfo.NumberFormatInfo() to set/retrive the info for the currency values.
I hope this help you.

-obislavu-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top