stdxdecimal 0.2.0

Proposal for a General Decimal Arithmetic type to Phobos


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Decimal Type for Phobos

This code is a work in progress for a new type Decimal that follows the "General Decimal Arithmetic Specification" http://speleotrove.com/decimal/decarith.html

Current Features

Feature | Implemented ------------ | ------------- Construction from strings/string-like ranges | ✓ Construction from number types | ✓ To decimal string | ✓ To scientific string | ❌ To engineering string | ❌ All rounding types | ❌ Equals | ❌ Compare | ❌ Addition/Subtraction | ❌ Multiply | ❌ Divide | ❌ abs | ❌ ln | ❌ log10 | ❌ exp | ❌ sqrt | ❌ power | ❌ reduce | ❌

Example

import stdxdecimal;

void main()
{
    auto d1 = decimal("1.23");
    auto d2 = decimal("1.23E-4");
    auto d3 = decimal("1.23E4");

    assert(d1.toString() == "1.23");
    assert(d2.toString() == "0.000123");
    assert(d3.toString() == "12300");
}
Authors:
Jack Stouffer
Dependencies:
none
Versions:
0.5.0 2018-Jan-05
0.4.0 2017-Dec-21
0.3.0 2017-Dec-08
0.2.0 2017-Dec-06
0.1.0 2017-Dec-02
Show all 6 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 2 downloads total