leaz / decimal_for_cpp Goto Github PK
View Code? Open in Web Editor NEWThis project forked from vpiotr/decimal_for_cpp
Decimal data type for C++
This project forked from vpiotr/decimal_for_cpp
Decimal data type for C++
Purpose: Decimal data type support, for COBOL-like fixed-point operations on currency/money values. Author: Piotr Likus Created: 03/01/2011 Modified: 01/02/2014 Licence: BSD Version: 1.5 This data type is designed to perform calculation with on-fly roundings & to support correct compare function (floating-point compare is unreliable). Values are stored internally using 64-bit integer, so maximum number of digits is 18. Precision is user-defined, so you can use this data type for currency rates. To store decimal in file you can use "unbiased" functions. Example usage: #include "decimal.h" using namespace dec; // the following declares currency variable with 2 decimal points // initialized with integer value (can be also floating-point) decimal<2> value(143125); // to use non-decimal constants you need to convert them to decimal value = value / decimal_cast<2>(333.0); // output values cout << "Result is: " << value << endl; // this should display something like "429.80" // to mix decimals with different precision use decimal_cast decimal<6> exchangeRate(12.1234); value = decimal_cast<2>(decimal_cast<6>(value) * exchangeRate); cout << "Result 2 is: " << value << endl; // this should display something like "5210.64" cout << "Result 2<6> is: " << decimal_cast<6>(value) << endl; // this should display something like "5210.640000" Directory structure: \doc - documentation (licence etc.) \include - headers \test - unit tests, Boost-based Code documentation can be generated using Doxygen: http://www.doxygen.org/ Tested compilers: - VS2010 Express SP1 - Code::Blocks 10.05 + MinGW + gcc 4.5
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.