Skip to content

Latest commit

 

History

History
68 lines (43 loc) · 1.74 KB

README.md

File metadata and controls

68 lines (43 loc) · 1.74 KB

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.