GithubHelp home page GithubHelp logo

fagan2888 / libfixed Goto Github PK

View Code? Open in Web Editor NEW

This project forked from oanda/libfixed

0.0 0.0 0.0 80 KB

A C++ fixed point math library suitable for financial applications.

License: MIT License

C++ 98.85% Makefile 1.15%

libfixed's Introduction

ABOUT

A C++ fixed point math library providing a Number class that can be used by all arithmetic and relational operators in place of using the floating point data types (float, double or long double). This is to provide the exact precision required by financial applications.

TESTED WITH

Linux x86 64bit

gcc 4.8.1

Required compile flags -std=gnu++11.

BUILDING

make

output will be build/libfixed.a

EXAMPLES

Include the file include/fixed/Number.h

Simply instantiate Numbers and use them in normal arithmetic and relational expressions.

  • Number (40) Produces a Number with a value of 40.
  • Number (-5, 2, 3) Produces a Number with the a value of -5.002.
  • Number (5, 2, 3, Number::Sign::NEGATIVE) Produces a Number with the value of -5.002.
  • Number (0, 2, 2, Number::Sign::NEGATIVE) Produces a Number with the value of -0.02.

Can also instantiate with a string, though this is more expensive than the integer based constructor.

  • Number ("1.0234") produces a number with a value of 1.0234

Also there are constructors that accept floating point values, but these are less accurate than the integer based versions. These are provided for completeness and convenience, though the integer based constructor is encouraged.

For the full details see include/fixed/Number.h

libfixed's People

Contributors

herbsears-oanda avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.