dec_number 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +20 -0
- data/dec_number.gemspec +13 -0
- data/ext/dec_number/Gemfile +4 -0
- data/ext/dec_number/NOTES +10 -0
- data/ext/dec_number/decNumber/ICU-license.html +45 -0
- data/ext/dec_number/decNumber/Makefile.am +3 -0
- data/ext/dec_number/decNumber/Makefile.in +680 -0
- data/ext/dec_number/decNumber/aclocal.m4 +8988 -0
- data/ext/dec_number/decNumber/autom4te.cache/output.0 +5107 -0
- data/ext/dec_number/decNumber/autom4te.cache/output.1 +6026 -0
- data/ext/dec_number/decNumber/autom4te.cache/output.2 +13468 -0
- data/ext/dec_number/decNumber/autom4te.cache/output.3 +13472 -0
- data/ext/dec_number/decNumber/autom4te.cache/requests +407 -0
- data/ext/dec_number/decNumber/autom4te.cache/traces.0 +352 -0
- data/ext/dec_number/decNumber/autom4te.cache/traces.1 +772 -0
- data/ext/dec_number/decNumber/autom4te.cache/traces.2 +591 -0
- data/ext/dec_number/decNumber/autom4te.cache/traces.3 +2362 -0
- data/ext/dec_number/decNumber/config.guess +1501 -0
- data/ext/dec_number/decNumber/config.h.in +142 -0
- data/ext/dec_number/decNumber/config.sub +1705 -0
- data/ext/dec_number/decNumber/configure +13468 -0
- data/ext/dec_number/decNumber/configure.ac +36 -0
- data/ext/dec_number/decNumber/decBasic.c +3908 -0
- data/ext/dec_number/decNumber/decCommon.c +1835 -0
- data/ext/dec_number/decNumber/decContext.c +437 -0
- data/ext/dec_number/decNumber/decContext.h +254 -0
- data/ext/dec_number/decNumber/decDPD.h +1185 -0
- data/ext/dec_number/decNumber/decDouble.c +140 -0
- data/ext/dec_number/decNumber/decDouble.h +155 -0
- data/ext/dec_number/decNumber/decNumber.c +8141 -0
- data/ext/dec_number/decNumber/decNumber.h +182 -0
- data/ext/dec_number/decNumber/decNumberLocal.h +757 -0
- data/ext/dec_number/decNumber/decPacked.c +220 -0
- data/ext/dec_number/decNumber/decPacked.h +52 -0
- data/ext/dec_number/decNumber/decQuad.c +135 -0
- data/ext/dec_number/decNumber/decQuad.h +177 -0
- data/ext/dec_number/decNumber/decSingle.c +71 -0
- data/ext/dec_number/decNumber/decSingle.h +86 -0
- data/ext/dec_number/decNumber/decimal128.c +553 -0
- data/ext/dec_number/decNumber/decimal128.h +81 -0
- data/ext/dec_number/decNumber/decimal32.c +476 -0
- data/ext/dec_number/decNumber/decimal32.h +81 -0
- data/ext/dec_number/decNumber/decimal64.c +839 -0
- data/ext/dec_number/decNumber/decimal64.h +83 -0
- data/ext/dec_number/decNumber/decnumber.pdf +0 -0
- data/ext/dec_number/decNumber/depcomp +630 -0
- data/ext/dec_number/decNumber/example1.c +38 -0
- data/ext/dec_number/decNumber/example2.c +52 -0
- data/ext/dec_number/decNumber/example3.c +64 -0
- data/ext/dec_number/decNumber/example4.c +61 -0
- data/ext/dec_number/decNumber/example5.c +36 -0
- data/ext/dec_number/decNumber/example6.c +61 -0
- data/ext/dec_number/decNumber/example7.c +35 -0
- data/ext/dec_number/decNumber/example8.c +39 -0
- data/ext/dec_number/decNumber/install-sh +520 -0
- data/ext/dec_number/decNumber/libdecNumber.a +0 -0
- data/ext/dec_number/decNumber/ltmain.sh +8745 -0
- data/ext/dec_number/decNumber/missing +376 -0
- data/ext/dec_number/decNumber/readme.txt +81 -0
- data/ext/dec_number/dec_number.c +464 -0
- data/ext/dec_number/extconf.rb +52 -0
- data/ext/dec_number/extconf2.rb +50 -0
- data/ext/dec_number/recompile.sh +3 -0
- data/ext/dec_number/test_dec_number.rb +236 -0
- data/ext/dec_number/test_numeric.rb +235 -0
- metadata +111 -0
data/README
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
WARNING! Pre-release, not finished.
|
2
|
+
|
3
|
+
DecNumber is a wrapper around ICU-decNumber (Copyright (c) IBM Corporation)
|
4
|
+
that subclasses Numeric.
|
5
|
+
|
6
|
+
The main benefit over BigDecimal and other things is that each instance carries it's own context around with it in a DecContext object. The context is what dertimines the precision and rounding behavior.
|
7
|
+
|
8
|
+
An example of this in use might be a gas station where there are pump prices with 10ths of cents and store prices with only cents. The register sets a precision of 2 rounding up, and it can use the prices reported from the pump without incident.
|
9
|
+
|
10
|
+
Another example is a database with Decimal columns with differing precision and where you can't accept using Floats.
|
11
|
+
|
12
|
+
Another use case would be bitcoin, where you need an arbitrary precision, mixed with dollars.
|
13
|
+
|
14
|
+
I don't expect to instantiate these object directly, instead I will bind them to SQL Decimal in an ORM, or using some sort of Money class.
|
15
|
+
|
16
|
+
If you'd like to help out, please write tests!
|
17
|
+
|
18
|
+
Currently they are not very good citizens of the Numeric family and try to give you back DecNumber objects whenever used. This is intentional. It might be a better idea in a Money class than returned from a db, however.
|
19
|
+
|
20
|
+
TODO: Most of the methods should accept a context as an argument. Currently the context is attached to the receiver.
|
data/dec_number.gemspec
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Gem::Specification.new do |s| # -*-ruby-*-
|
2
|
+
s.name = "dec_number"
|
3
|
+
s.version = '0.0.0'
|
4
|
+
s.authors = ["Paris Sinclair"]
|
5
|
+
s.email = ["paris@rubypanther.com"]
|
6
|
+
s.summary = "ICU-decNumber wrapper for arbitrary precision math with context objects"
|
7
|
+
s.description = "Wrapper for ICU-decNumber library"
|
8
|
+
s.homepage = "http://github.com/rubypanther/dec_number"
|
9
|
+
s.extensions << 'ext/dec_number/extconf.rb'
|
10
|
+
s.rubyforge_project = "dec-number"
|
11
|
+
s.files = Dir['**/**']
|
12
|
+
end
|
13
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# gcc -fPIC -g -O2 -I/home/paris/.rvm/rubies/ruby-1.9.2-p180/include/ruby-1.9.1/x86_64-linux -I/home/paris/.rvm/rubies/ruby-1.9.2-p180/include/ruby-1.9.1/ -c decNumber.c decContext.c dec_number.c
|
2
|
+
# gcc -shared -o dec_number.so dec_number.o decNumber.o decContext.o -lc
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
gcc -fPIC -g -O2 -IdecNumber -c decNumber/decNumber.c decNumber/decContext.c
|
7
|
+
gcc -fPIC -g -O2 -I/home/paris/.rvm/rubies/ruby-1.9.2-p180/include/ruby-1.9.1/x86_64-linux -I/home/paris/.rvm/rubies/ruby-1.9.2-p180/include/ruby-1.9.1/ -IdecNumber -c dec_number.c
|
8
|
+
gcc -shared -o dec_number.so dec_number.o decNumber.o decContext.o -lc
|
9
|
+
ruby -I. -e 'require "dec_number"; DecNumber.new(1.23)'
|
10
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<html>
|
2
|
+
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></meta>
|
5
|
+
<title>ICU License - ICU 1.8.1 and later</title>
|
6
|
+
</head>
|
7
|
+
|
8
|
+
<body>
|
9
|
+
<h1>ICU License - ICU 1.8.1 and later</h1>
|
10
|
+
<pre>
|
11
|
+
COPYRIGHT AND PERMISSION NOTICE
|
12
|
+
|
13
|
+
Copyright (c) 1995-2005 International Business Machines Corporation and others
|
14
|
+
All rights reserved.
|
15
|
+
|
16
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
17
|
+
copy of this software and associated documentation files (the
|
18
|
+
"Software"), to deal in the Software without restriction, including
|
19
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
20
|
+
distribute, and/or sell copies of the Software, and to permit persons
|
21
|
+
to whom the Software is furnished to do so, provided that the above
|
22
|
+
copyright notice(s) and this permission notice appear in all copies of
|
23
|
+
the Software and that both the above copyright notice(s) and this
|
24
|
+
permission notice appear in supporting documentation.
|
25
|
+
|
26
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
27
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
28
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
29
|
+
OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
30
|
+
HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
|
31
|
+
INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
|
32
|
+
FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
33
|
+
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
34
|
+
WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
35
|
+
|
36
|
+
Except as contained in this notice, the name of a copyright holder
|
37
|
+
shall not be used in advertising or otherwise to promote the sale, use
|
38
|
+
or other dealings in this Software without prior written authorization
|
39
|
+
of the copyright holder.
|
40
|
+
|
41
|
+
--------------------------------------------------------------------------------
|
42
|
+
All trademarks and registered trademarks mentioned herein are the property of their respective owners.
|
43
|
+
</pre>
|
44
|
+
</body>
|
45
|
+
</html>
|