Lua decnumber bindings
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
decNumber
doc
examples
test
.gitignore
.travis.mk
.travis.yml
AUTHORS
CHANGELOG.md
CMakeLists.txt
FindTarantool.cmake
LICENSE
README.md
ldecNumber.c
ldecnumber-scm-1.rockspec

README.md

Build Status

Intro

ldecnumber -- a tarantool (luajit, Lua 5.1) wrapper for the decNumber Decimal Arithmetic package.

The wrapper and decNumber library are built as a monolithic Lua module.

Installing

tarantoolctl rocks install https://raw.githubusercontent.com/tarantool/ldecnumber/master/ldecnumber-scm-1.rockspec

Example

Single user billing system

decnumber = require('ldecnumber')

local balance = decnumber.tonumber("0.00")

-- put some money
balance = balance + "0.01"

-- once again a little bit more
balance = balance + "1.25"


-- take some money
balance = balance - "1.12"

-- check balance value is valid
balance:isfinite() --> true
balance:isinfinite() --> false
balance:isnan() --> false

-- send balance to report system
balance:tostring() --> '0.14'

Documentation

Links

Copyrights

The Lua wrapper is Copyright (c) 2006-7 Doug Currie, Londonderry, NH All rights reserved.

The decNumber C library is Copyright (c) 1995-2005 International Business Machines Corporation and others All rights reserved.

The software and documentation is made available under the terms of the ICU License (ICU 1.8.1 and later) included in the package as decNumber/ICU-license.html.