tags:

views:

56

answers:

2

I am currently working on a program that takes Visual Basic data in the form of a text file, and then stores this data in C++. Some of the data from Visual Basic is of the type Decimal. C++ has no built in type equivalent to decimal. I don't want to use double because there is a possible loss of significant figures if the numbers are large enough.

One option is write my own decimal class. I was wondering if there were any other alternatives for solving this problem before I attempted to do that.

Thanks for you help.

A: 

There's the decNumber library. This is a C library designed for use with decimal numbers without losing precision/accuracy.

Given that it's a C library, you should be able to easily wrap it in a C++ class, or just use the C functions directly

This is an IBM sponsored lib and it's available under an open source license (ICU)

Glen
A: 

Using a Decimal class is the best solution in my opinion. As to writing your own implementation, try a short web research first: It seems that others had the same problem before. The first Google result reveals a CodeProject solution, there may be many other...

MartinStettner