Description

Checked integer math types and operations.

Package Information

Version0.5.3 (2016-Jun-09)
Repository https://github.com/tsbockman/checkedint
LicenseBSL-1.0
CopyrightCopyright © 2015, Thomas Stuart Bockman
AuthorsThomas Stuart Bockman
Registered byThomas Stuart Bockman
Sub packages
checkedint:tests
Exhaustive tests for the checkedint package. Verifies correctness and measures performance.
Dependencies none

Installation

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

dub.json
dub.sdl

Readme

Checked integer math module for the D Programming Language

As with many other languages (C, C++, Java, etc.), D's built-in integer data types are quite difficult to use correctly.

It is tempting to think of int, for example, as if it were an actual mathematical integer. Doing so, however leads to buggy code due to unintuitive behaviour like:

  • Wrapped overflow
  • Reinterpretation of signed values as unsigned in mixed expressions
  • Floating Point Exceptions which aren't Exceptions and have nothing to do with floating point
  • Formally "undefined behaviour" with some inputs for various operations

This checkedint module provides alternative operations and types that protect the user from most difficulties of this sort, while maintaining good performance (provided that inlining and optimizations are enabled).

The main downsides to using checkedint are:

  • Some added friction when interfacing to non-checkedint-aware code.
  • Slower compilation and larger binaries.

Use dub build -b docs to generate more extensive documentation for this package.

Installation

This library is available as a DUB package: http://code.dlang.org/packages/checkedint

Available versions

0.5.3 0.5.2 0.5.1 0.5.0 0.4.5 0.4.4 0.4.3 0.4.2 0.4.0 0.3.1 0.3.0 0.2.2 0.2.1 0.2.0 0.1.2 0.1.1 0.1.0 ~master