From 798ccf7f0b12732c739a53a55d89837511e01757 Mon Sep 17 00:00:00 2001 From: Paul V Puey Date: Fri, 16 Dec 2022 15:21:14 -0800 Subject: [PATCH] v4.1.0 --- CHANGELOG.md | 6 ++++++ README.md | 50 ++++++++++++++++++++++++++++++++------------------ package.json | 2 +- 3 files changed, 39 insertions(+), 19 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..2f9dbcc --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,6 @@ +# biggystring + +## 4.1.0 (2022-12-16) + +- add: floor, ceil, round functions +- change: Modernize testing workflow \ No newline at end of file diff --git a/README.md b/README.md index 437c233..cf17cb1 100644 --- a/README.md +++ b/README.md @@ -12,32 +12,46 @@ Floating point big number library using only strings as inputs and outputs ### Basic Math - console.log(bs.add('32', '10') // => '42' - console.log(bs.sub('32', '10') // => '22' - console.log(bs.mul('32', '10') // => '320' - console.log(bs.div('32', '10') // => '3' Truncates remainder + bs.add('32', '10') // => '42' + bs.sub('32', '10') // => '22' + bs.mul('32', '10') // => '320' + bs.div('32', '10') // => '3' Truncates remainder ### Hex - console.log(bs.add('0xa', '10') // => '20' - console.log(bs.add('0xa', '0x20') // => '42' - console.log(bs.add('10', '0x10') // => '26' + bs.add('0xa', '10') // => '20' + bs.add('0xa', '0x20') // => '42' + bs.add('10', '0x10') // => '26' ### Comparisons - console.log(bs.gt('32', '10') // => True - console.log(bs.lt('32', '10') // => False - console.log(bs.gte('32', '32') // => True - console.log(bs.lte('32', '10') // => False - console.log(bs.eq('32', '10') // => False - console.log(bs.eq('32', '32') // => True + bs.gt('32', '10') // => True + bs.lt('32', '10') // => False + bs.gte('32', '32') // => True + bs.lte('32', '10') // => False + bs.eq('32', '10') // => False + bs.eq('32', '32') // => True ### Floating point operations (base 10 only) - console.log(bs.add('3.2', '1.3') // => '4.5' - console.log(bs.sub('3.2', '1.3') // => '1.9' - console.log(bs.mul('3.2', '1.3') // => '4.16' + bs.add('3.2', '1.3') // => '4.5' + bs.sub('3.2', '1.3') // => '1.9' + bs.mul('3.2', '1.3') // => '4.16' // For `div`, 3rd arg is decimal precision, 4th arg is base - console.log(bs.div('10', '3.0', 5, 10) // => '3.33333' - console.log(bs.div('1.23', '3.3', 5, 10) // => '0.37272' + bs.div('10', '3.0', 5, 10) // => '3.33333' + bs.div('1.23', '3.3', 5, 10) // => '0.37272' + +### Rounding functions (base 10 only) + + bs.floor('123.456', 0) => '123' + bs.floor('123.456', 1) => '120' + bs.floor('123.456', -1) => '123.4' + + bs.ceil('123.456', 0) => '124' + bs.ceil('123.456', 1) => '130' + bs.ceil('123.456', -1) => '123.5' + + bs.round('123.456', 0) => '123' + bs.round('125.456', 1) => '130' + bs.round('123.456', -1) => '123.5' diff --git a/package.json b/package.json index 24f2e08..58e68dd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "biggystring", - "version": "4.0.0", + "version": "4.1.0", "description": "Full floating point big number library using regular Javascript string", "keywords": [ "big",