Skip to content

allegory-software/allegory-sdk-ldecnumber

 
 

Repository files navigation

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.

About

decNumber library + Lua/C binding

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 88.0%
  • Lua 11.3%
  • Other 0.7%