开发者

Alternatives for accurately representing Visual Basic Decimal variables in C++

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开发者_如何学Go for solving this problem before I attempted to do that.

Thanks for you help.


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)


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜