long-decimal 0.00.22 → 0.01.00
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 +157 -32
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/doc/classes/LongDecimal.src/M000036.html +1 -1
- data/doc/classes/LongDecimal.src/M000037.html +1 -1
- data/doc/classes/LongDecimal.src/M000038.html +1 -1
- data/doc/classes/LongDecimal.src/M000039.html +1 -1
- data/doc/classes/LongDecimal.src/M000040.html +1 -1
- data/doc/classes/LongDecimal.src/M000041.html +1 -1
- data/doc/classes/LongDecimal.src/M000042.html +1 -1
- data/doc/classes/LongDecimal.src/M000043.html +1 -1
- data/doc/classes/LongDecimal.src/M000044.html +1 -1
- data/doc/classes/LongDecimal.src/M000045.html +1 -1
- data/doc/classes/LongDecimal.src/M000046.html +1 -1
- data/doc/classes/LongDecimal.src/M000047.html +1 -1
- data/doc/classes/LongDecimal.src/M000048.html +1 -1
- data/doc/classes/LongDecimal.src/M000049.html +1 -1
- data/doc/classes/LongDecimal.src/M000050.html +1 -1
- data/doc/classes/LongDecimal.src/M000051.html +1 -1
- data/doc/classes/LongDecimal.src/M000052.html +1 -1
- data/doc/classes/LongDecimal.src/M000053.html +1 -1
- data/doc/classes/LongDecimal.src/M000054.html +1 -1
- data/doc/classes/LongDecimal.src/M000055.html +1 -1
- data/doc/classes/LongDecimal.src/M000056.html +1 -1
- data/doc/classes/LongDecimal.src/M000057.html +1 -1
- data/doc/classes/LongDecimal.src/M000058.html +1 -1
- data/doc/classes/LongDecimal.src/M000059.html +1 -1
- data/doc/classes/LongDecimal.src/M000060.html +1 -1
- data/doc/classes/LongDecimal.src/M000062.html +1 -1
- data/doc/classes/LongDecimal.src/M000063.html +1 -1
- data/doc/classes/LongDecimal.src/M000064.html +1 -1
- data/doc/classes/LongDecimal.src/M000065.html +1 -1
- data/doc/classes/LongDecimal.src/M000066.html +1 -1
- data/doc/classes/LongDecimal.src/M000067.html +1 -1
- data/doc/classes/LongDecimal.src/M000068.html +1 -1
- data/doc/classes/LongDecimal.src/M000069.html +1 -1
- data/doc/classes/LongDecimal.src/M000070.html +1 -1
- data/doc/classes/LongDecimal.src/M000071.html +6 -2
- data/doc/classes/LongDecimal.src/M000072.html +1 -1
- data/doc/classes/LongDecimal.src/M000073.html +1 -1
- data/doc/classes/LongDecimal.src/M000074.html +1 -1
- data/doc/classes/LongDecimal.src/M000075.html +1 -1
- data/doc/classes/LongDecimal.src/M000076.html +1 -1
- data/doc/classes/LongDecimal.src/M000077.html +1 -1
- data/doc/classes/LongDecimal.src/M000078.html +1 -1
- data/doc/classes/LongDecimal.src/M000079.html +1 -1
- data/doc/classes/LongDecimal.src/M000080.html +1 -1
- data/doc/classes/LongDecimal.src/M000081.html +1 -1
- data/doc/classes/LongDecimal.src/M000082.html +1 -1
- data/doc/classes/LongDecimal.src/M000083.html +1 -1
- data/doc/classes/LongDecimal.src/M000084.html +1 -1
- data/doc/classes/LongDecimal.src/M000085.html +1 -1
- data/doc/classes/LongDecimal.src/M000086.html +1 -1
- data/doc/classes/LongDecimal.src/M000087.html +1 -1
- data/doc/classes/LongDecimal.src/M000088.html +1 -1
- data/doc/classes/LongDecimal.src/M000089.html +1 -1
- data/doc/classes/LongDecimal.src/M000090.html +1 -1
- data/doc/classes/LongDecimal.src/M000091.html +1 -1
- data/doc/classes/LongDecimal.src/M000092.html +1 -1
- data/doc/classes/LongDecimal.src/M000093.html +1 -1
- data/doc/classes/LongDecimal.src/M000094.html +1 -1
- data/doc/classes/LongDecimal.src/M000095.html +1 -1
- data/doc/classes/LongDecimal.src/M000098.html +1 -1
- data/doc/classes/LongDecimal.src/M000099.html +1 -1
- data/doc/classes/LongDecimal.src/M000100.html +1 -1
- data/doc/classes/LongDecimal.src/M000101.html +1 -1
- data/doc/classes/LongDecimal.src/M000102.html +18 -0
- data/doc/classes/LongDecimal.src/M000103.html +18 -0
- data/doc/classes/LongDecimalBase.src/M000107.html +1 -1
- data/doc/classes/LongDecimalBase.src/M000108.html +1 -1
- data/doc/classes/LongDecimalBase.src/M000109.html +1 -1
- data/doc/classes/LongDecimalBase.src/M000110.html +1 -1
- data/doc/classes/LongDecimalBase.src/M000111.html +1 -1
- data/doc/classes/LongDecimalBase.src/M000112.html +1 -1
- data/doc/classes/LongDecimalBase.src/M000115.html +1 -1
- data/doc/classes/LongDecimalBase.src/M000116.html +19 -0
- data/doc/classes/LongDecimalBase.src/M000117.html +18 -0
- data/doc/classes/LongDecimalQuot.src/M000003.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000004.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000005.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000006.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000007.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000008.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000009.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000010.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000011.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000012.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000013.html +13 -2
- data/doc/classes/LongDecimalQuot.src/M000014.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000015.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000016.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000017.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000018.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000019.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000020.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000021.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000022.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000023.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000024.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000025.html +18 -1
- data/doc/classes/LongDecimalQuot.src/M000026.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000027.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000028.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000029.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000030.html +18 -0
- data/doc/classes/LongDecimalQuot.src/M000031.html +18 -0
- data/doc/classes/LongDecimalQuot.src/M000034.html +18 -0
- data/doc/classes/LongDecimalQuot.src/M000035.html +18 -0
- data/doc/classes/LongDecimalRoundingMode.html +17 -2
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.html +17 -2
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000150.html +22 -0
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000151.html +18 -0
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000152.html +18 -0
- data/doc/classes/LongMath.src/M000118.html +1 -1
- data/doc/classes/LongMath.src/M000119.html +1 -1
- data/doc/classes/LongMath.src/M000120.html +1 -1
- data/doc/classes/LongMath.src/M000121.html +1 -1
- data/doc/classes/LongMath.src/M000122.html +1 -1
- data/doc/classes/LongMath.src/M000123.html +1 -1
- data/doc/classes/LongMath.src/M000124.html +1 -1
- data/doc/classes/LongMath.src/M000125.html +1 -1
- data/doc/classes/LongMath.src/M000126.html +1 -1
- data/doc/classes/LongMath.src/M000127.html +1 -1
- data/doc/classes/LongMath.src/M000128.html +1 -1
- data/doc/classes/LongMath.src/M000129.html +1 -1
- data/doc/classes/LongMath.src/M000130.html +1 -1
- data/doc/classes/LongMath.src/M000131.html +1 -1
- data/doc/classes/LongMath.src/M000132.html +1 -1
- data/doc/classes/LongMath.src/M000133.html +1 -1
- data/doc/classes/LongMath.src/M000134.html +1 -1
- data/doc/classes/LongMath.src/M000135.html +1 -1
- data/doc/classes/LongMath.src/M000136.html +1 -1
- data/doc/classes/LongMath.src/M000137.html +11 -3
- data/doc/classes/LongMath.src/M000138.html +2 -1
- data/doc/classes/LongMath.src/M000139.html +1 -1
- data/doc/classes/LongMath.src/M000140.html +1 -1
- data/doc/classes/LongMath.src/M000141.html +1 -1
- data/doc/classes/LongMath.src/M000142.html +2 -2
- data/doc/classes/LongMath.src/M000143.html +2 -2
- data/doc/classes/LongMath.src/M000144.html +3 -2
- data/doc/classes/LongMath.src/M000145.html +20 -10
- data/doc/classes/LongMath.src/M000146.html +3 -2
- data/doc/classes/LongMath.src/M000147.html +80 -0
- data/doc/classes/LongMath.src/M000148.html +63 -0
- data/doc/classes/LongMath/CacheKey.src/M000149.html +36 -0
- data/doc/classes/Numeric.src/M000104.html +23 -0
- data/doc/classes/Numeric.src/M000105.html +18 -0
- data/doc/classes/Rational.src/M000106.html +23 -0
- data/doc/created.rid +1 -1
- data/doc/files/lib/long-decimal_rb.html +189 -0
- data/doc/files/lib/long-decimal_rb.src/M000001.html +1 -1
- data/doc/files/lib/long-decimal_rb.src/M000002.html +1 -1
- data/doc/fr_method_index.html +20 -19
- data/lib/long-decimal.rb +105 -30
- data/test/testlongdecimal.rb +448 -3
- data/test/testlongdeclib.rb +127 -28
- data/test/testrandom.rb +35 -22
- data/version.rb +4 -4
- metadata +20 -2
data/README
CHANGED
@@ -1,31 +1,13 @@
|
|
1
1
|
Version
|
2
2
|
-------
|
3
3
|
|
4
|
-
This version ($Name:
|
5
|
-
pre-alpha-0.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
There are no known bugs and this version can be considered complete in
|
13
|
-
terms of functionality. This version is still a pre-alpha-version,
|
14
|
-
but it is expected to move it to alpha within the next days of weeks,
|
15
|
-
after having added some more tests and having fixed potential bugs
|
16
|
-
that these tests might reveal. The first alpha version is not
|
17
|
-
expected to be much different from this version. This version should
|
18
|
-
already be usable. Operations +, -, *, / and sqrt should be working
|
19
|
-
properly and would justify calling this release at least beta. Even
|
20
|
-
log, exp and power should be fine, but they might have some issues in
|
21
|
-
terms of precision, so that the last digits of the result might be
|
22
|
-
wrong, or in terms of speed. For this reason they are currently
|
23
|
-
considered to be alpha, as soon as significant amount testing with
|
24
|
-
random numbers as parameters has been performed. It would be a good
|
25
|
-
idea to do some mathematical analysis on how many digits are needed
|
26
|
-
internally to guarantee the correctness of the digits that are
|
27
|
-
provided. But this will not be considered as a requirement for the
|
28
|
-
alpha-version.
|
4
|
+
This version ($Name: ALPHA_01_00 $) is functionally identical with the previous
|
5
|
+
pre-alpha-0.22. The runit tests have been extended and further tests
|
6
|
+
have been added. A lot of additional testing has been done using
|
7
|
+
random numbers as parameters with testrandom.rb and values for which
|
8
|
+
these random tests have failed have been added to the regular tests in
|
9
|
+
testlongdecimal.rb . So this release is mostly bug-fixing, enough to
|
10
|
+
justify declaring itself as alpha-version.
|
29
11
|
|
30
12
|
This software development effort is hosted on RubyForge (
|
31
13
|
http://rubyforge.org/ ) under the project name "long-decimal", to be
|
@@ -33,6 +15,26 @@ found directly with http://rubyforge.org/projects/long-decimal/ . So
|
|
33
15
|
you should feel encouraged to look if there is a newer version, when
|
34
16
|
you install long-decimal.
|
35
17
|
|
18
|
+
This version is a alpha-version. Operations +, -, *, / and sqrt
|
19
|
+
should be working properly and would justify calling this release at
|
20
|
+
least beta. Even log, exp and power should be fine. log, log2, log10
|
21
|
+
and exp have been tested for about a million random values and the
|
22
|
+
current version should cover all of these correctly. But it is still
|
23
|
+
possible,that in some cases the result deviates in the last digit by 1
|
24
|
+
or 2 from the real result. A deviation of slightly more than half of
|
25
|
+
the unit of the last digit is already present. Improving on this
|
26
|
+
would require an extensive extension of internal functionality to
|
27
|
+
provide rounding information in case of last digits being 50000...,
|
28
|
+
where additional digits would reveal if this really needs to be
|
29
|
+
rounded up or down. Because these functions are transcendental, at
|
30
|
+
least exp and log will always have either one of these true, it will
|
31
|
+
never be exactly ....5. Speed could be improved as well.
|
32
|
+
|
33
|
+
It would be a good idea to do some mathematical analysis on how many
|
34
|
+
digits are needed internally to guarantee the correctness of the
|
35
|
+
digits that are provided. But this will not be considered as a
|
36
|
+
requirement for the alpha-version.
|
37
|
+
|
36
38
|
Test
|
37
39
|
----
|
38
40
|
|
@@ -48,8 +50,12 @@ your machine. It is about 15 minutes on my machine (1300 MHz).
|
|
48
50
|
Whatever is gained by making the software run faster is used up again
|
49
51
|
by adding more tests. This is the result of the test:
|
50
52
|
|
51
|
-
|
52
|
-
|
53
|
+
In addition random tests for exp, log, log2 and log10 can be run for a
|
54
|
+
long time, using the script test/testrandom.rb. This requires
|
55
|
+
installation of the ruby-library crypt-isaac for its random numbers.
|
56
|
+
If you actually want to run this and find an error with it, please
|
57
|
+
report it with the lines of output revealing the bug on
|
58
|
+
http://rubyforge.org/projects/long-decimal/ -> tracker
|
53
59
|
|
54
60
|
Install
|
55
61
|
-------
|
@@ -100,7 +106,7 @@ ruby 1.8.4 and on Windows 2000 with ruby 1.8.2)
|
|
100
106
|
- open a shell window
|
101
107
|
cd to the directory where you have downloaded the gem-file
|
102
108
|
unpack the file using tar
|
103
|
-
tar xfzvv long-decimal-
|
109
|
+
tar xfzvv long-decimal-alpha-1_00.tar.gz
|
104
110
|
cd long-decimal
|
105
111
|
- now you can use rake for several operations
|
106
112
|
- rake test
|
@@ -116,6 +122,125 @@ ruby 1.8.4 and on Windows 2000 with ruby 1.8.2)
|
|
116
122
|
3. The documentation can be created from the sources. It is contained
|
117
123
|
in the gem-file. It is not provided as a separate file any more.
|
118
124
|
|
125
|
+
Install
|
126
|
+
-------
|
127
|
+
|
128
|
+
(REMARK: installation has only been successfully tested on Linux with
|
129
|
+
ruby 1.8.4 and on Windows 2000 with ruby 1.8.2)
|
130
|
+
|
131
|
+
1. Using ruby-gems (preferred)
|
132
|
+
- open a shell window
|
133
|
+
- become root, unless the current user has the right to install gems
|
134
|
+
(which is usually the case on windows)
|
135
|
+
|
136
|
+
su
|
137
|
+
|
138
|
+
- uninstall old versions
|
139
|
+
|
140
|
+
gem uninstall long-decimal
|
141
|
+
|
142
|
+
- install the newest version
|
143
|
+
|
144
|
+
gem install long-decimal
|
145
|
+
|
146
|
+
- Usage from your ruby-programs:
|
147
|
+
|
148
|
+
require "rubygems"
|
149
|
+
require_gem "long-decimal"
|
150
|
+
|
151
|
+
- documentation will be found in HTML-format in the directory
|
152
|
+
$RUBY_DIR/gems/$RUBY_VERSION/doc/long-decimal-$LONG_DECIMAL_VERSION/rdoc/index.html
|
153
|
+
where $RUBY_DIR is the directory containing your ruby-installation,
|
154
|
+
usually /usr/lib/ruby or /usr/local/lib/ruby on
|
155
|
+
Linux/Unix-systems.
|
156
|
+
$RUBY_VERSION is the major version of your Ruby, like 1.8
|
157
|
+
$LONG_DECIMAL_VERSION is the version of long-decimal that you
|
158
|
+
have installed, like 0.00.20
|
159
|
+
on my machine that would be
|
160
|
+
/usr/local/lib/ruby/gems/1.8/doc/long-decimal-0.00.20/rdoc/index.html
|
161
|
+
|
162
|
+
2. Installing from the sources (it is preferred to use the
|
163
|
+
gem-installation, but since long-decimal is open-source-software you
|
164
|
+
are off course granted the right to download the source and change
|
165
|
+
it and install your own version.
|
166
|
+
|
167
|
+
- download the newest source-tar.gz-file from long-decimal project at rubyforge
|
168
|
+
which can be found by
|
169
|
+
http://rubyforge.org/projects/long-decimal/ -> Files
|
170
|
+
( http://rubyforge.org/frs/?group_id=1334 )
|
171
|
+
- open a shell window
|
172
|
+
cd to the directory where you have downloaded the gem-file
|
173
|
+
unpack the file using tar
|
174
|
+
tar xfzvv long-decimal-alpha-1_00.tar.gz
|
175
|
+
cd long-decimal
|
176
|
+
- now you can use rake for several operations
|
177
|
+
- rake test
|
178
|
+
runs runit tests. All tests should succeed.
|
179
|
+
- rake doc
|
180
|
+
creates the documentation
|
181
|
+
- rake gem creates the gem-file in a sub-directory pkg
|
182
|
+
recommended for installation, proceed as in 1
|
183
|
+
- cd pkg
|
184
|
+
- gem install --local long-decimal
|
185
|
+
|
186
|
+
|
187
|
+
3. The documentation can be created from the sources. It is contained
|
188
|
+
in the gem-file. It is not provided as a separate file any more.
|
189
|
+
|
190
|
+
Test
|
191
|
+
----
|
192
|
+
|
193
|
+
Some runit tests have been included. They give some indication of the
|
194
|
+
correctness of this library and allow changes to be checked in order
|
195
|
+
to make sure that what was running before would still work afterwards.
|
196
|
+
Tests for a library as complex as long-decimal can never be
|
197
|
+
exhaustive, but they give a good indication that methods are working
|
198
|
+
correctly. About 95% of the tests that will be eventually needed are
|
199
|
+
already present. As a policy a release is not created unless all
|
200
|
+
tests succeed. Running the tests can take a few minutes, depending on
|
201
|
+
your machine. It is about 15 minutes on my machine (1300 MHz).
|
202
|
+
Whatever is gained by making the software run faster is used up again
|
203
|
+
by adding more tests. This is the result of the test:
|
204
|
+
|
205
|
+
Finished in 1735.081239 seconds.
|
206
|
+
125 tests, 44932 assertions, 0 failures, 0 errors
|
207
|
+
|
208
|
+
Bugs
|
209
|
+
----
|
210
|
+
|
211
|
+
There are no known bugs against the current specification and bugs
|
212
|
+
that occur are usually fixed within a few days.
|
213
|
+
|
214
|
+
It is considered somewhat arbitrary to disallow calculation
|
215
|
+
exponential functions if the result could not be expressed as Float.
|
216
|
+
This limitation should be removed, even though it has to be added,
|
217
|
+
that results of exponentiation that go beyond Float can only be handled
|
218
|
+
at a great cost of performance, because they really need more than 300
|
219
|
+
digits.
|
220
|
+
|
221
|
+
Certain calculations are too slow. Algorithms need to be optimized
|
222
|
+
for speed. The goal is to keep the algorithms in Ruby-code as long as
|
223
|
+
possible to make it easier to optimize the algorithm. If optimization
|
224
|
+
beyond this level will be needed, C-code might be used, preferably
|
225
|
+
based on an existing library.
|
226
|
+
|
227
|
+
Even though some mathematical background has already been invested,
|
228
|
+
more effort from the theoretical side is needed in order to choose
|
229
|
+
internal precision parameters in such a way that correctness of the
|
230
|
+
result to all given digits can be guaranteed with a minimum of
|
231
|
+
overhead. Currently parameters are probably slightly too careful,
|
232
|
+
which slows calculations down. But it is also possible that they are
|
233
|
+
insufficient for certain calculations, yielding wrong results.
|
234
|
+
|
235
|
+
rdoc-documentation and in-code comments are somewhat complete, but for
|
236
|
+
a sophisticated library like this additional external documentation
|
237
|
+
should be provided. Currently this does not exist at all.
|
238
|
+
|
239
|
+
Please report any bugs you come across on
|
240
|
+
http://rubyforge.org/projects/long-decimal -> Tracker.
|
241
|
+
|
242
|
+
The status of long-decimal is considered to be alpha.
|
243
|
+
|
119
244
|
License
|
120
245
|
-------
|
121
246
|
|
@@ -125,10 +250,10 @@ Find copies of these licenses on http://www.gnu.org/ or http://www.ruby-lang.org
|
|
125
250
|
Warranty
|
126
251
|
--------
|
127
252
|
|
128
|
-
This is a
|
129
|
-
I do not take any responsibility. Please use it as it is,
|
130
|
-
according to the terms of the license or wait for a more
|
131
|
-
version (for
|
253
|
+
This is a alpha-version. Do not expect too much! This is work in
|
254
|
+
progress! I do not take any responsibility. Please use it as it is,
|
255
|
+
change it according to the terms of the license or wait for a more
|
256
|
+
stable version (for which I can't take any warranty either...)
|
132
257
|
|
133
258
|
Author
|
134
259
|
------
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.00
|
1
|
+
0.01.00
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 207</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">LongDecimal</span>.<span class="ruby-identifier">new!</span>(<span class="ruby-identifier">x</span>, <span class="ruby-identifier">s</span> = <span class="ruby-value">0</span>)
|
15
15
|
<span class="ruby-identifier">new</span>(<span class="ruby-identifier">x</span>, <span class="ruby-identifier">s</span>)
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 215</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">LongDecimal</span>.<span class="ruby-identifier">zero!</span>(<span class="ruby-identifier">s</span> = <span class="ruby-value">0</span>)
|
15
15
|
<span class="ruby-identifier">new</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">s</span>)
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 224</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">LongDecimal</span>.<span class="ruby-identifier">one!</span>(<span class="ruby-identifier">s</span> = <span class="ruby-value">0</span>)
|
15
15
|
<span class="ruby-identifier">new</span>(<span class="ruby-value">10</span><span class="ruby-operator">**</span><span class="ruby-identifier">s</span>, <span class="ruby-identifier">s</span>)
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 233</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">LongDecimal</span>.<span class="ruby-identifier">two!</span>(<span class="ruby-identifier">s</span> = <span class="ruby-value">0</span>)
|
15
15
|
<span class="ruby-identifier">new</span>(<span class="ruby-value">2</span><span class="ruby-operator">*</span><span class="ruby-value">10</span><span class="ruby-operator">**</span><span class="ruby-identifier">s</span>, <span class="ruby-identifier">s</span>)
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 242</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">LongDecimal</span>.<span class="ruby-identifier">ten!</span>(<span class="ruby-identifier">s</span> = <span class="ruby-value">0</span>)
|
15
15
|
<span class="ruby-identifier">new</span>(<span class="ruby-value">10</span><span class="ruby-operator">**</span>(<span class="ruby-identifier">s</span><span class="ruby-operator">+</span><span class="ruby-value">1</span>), <span class="ruby-identifier">s</span>)
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 251</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">LongDecimal</span>.<span class="ruby-identifier">minus_one!</span>(<span class="ruby-identifier">s</span> = <span class="ruby-value">0</span>)
|
15
15
|
<span class="ruby-identifier">new</span>(<span class="ruby-value">-1</span><span class="ruby-operator">*</span><span class="ruby-value">10</span><span class="ruby-operator">**</span><span class="ruby-identifier">s</span>, <span class="ruby-identifier">s</span>)
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 261</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">LongDecimal</span>.<span class="ruby-identifier">power_of_ten!</span>(<span class="ruby-identifier">e</span>, <span class="ruby-identifier">s</span> = <span class="ruby-value">0</span>)
|
15
15
|
<span class="ruby-constant">LongMath</span>.<span class="ruby-identifier">check_is_int</span>(<span class="ruby-identifier">e</span>, <span class="ruby-value str">"e"</span>)
|
16
16
|
<span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">"negative 1st arg \"#{e.inspect}\""</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">e</span> <span class="ruby-operator"><</span> <span class="ruby-value">0</span>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 274</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">x</span>, <span class="ruby-identifier">s</span>)
|
15
15
|
|
16
16
|
<span class="ruby-comment cmt"># handle some obvious errors with x first</span>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 388</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">scale=</span>(<span class="ruby-identifier">s</span>)
|
15
15
|
<span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">"non integer arg \"#{s.inspect}\""</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Integer</span>
|
16
16
|
<span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">"negative arg \"#{s.inspect}\""</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">s</span> <span class="ruby-operator"><</span> <span class="ruby-value">0</span>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 414</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">round_trailing_zeros</span>
|
15
15
|
<span class="ruby-identifier">n</span> = <span class="ruby-constant">LongMath</span>.<span class="ruby-identifier">multiplicity_of_10</span>(<span class="ruby-identifier">int_val</span>)
|
16
16
|
<span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">n</span>.<span class="ruby-identifier">zero?</span>) <span class="ruby-keyword kw">then</span>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 433</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">round_to_scale</span>(<span class="ruby-identifier">new_scale</span>, <span class="ruby-identifier">mode</span> = <span class="ruby-constant">ROUND_UNNECESSARY</span>)
|
15
15
|
|
16
16
|
<span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">"new_scale #{new_scale.inspect} must be integer"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">new_scale</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Integer</span>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 472</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>(<span class="ruby-identifier">shown_scale</span> = <span class="ruby-ivar">@scale</span>, <span class="ruby-identifier">mode</span> = <span class="ruby-constant">ROUND_UNNECESSARY</span>, <span class="ruby-identifier">base</span> = <span class="ruby-value">10</span>)
|
15
15
|
<span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">base</span> <span class="ruby-operator">==</span> <span class="ruby-value">10</span>) <span class="ruby-keyword kw">then</span>
|
16
16
|
<span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">shown_scale</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@scale</span>)
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 495</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s_10</span>
|
15
15
|
<span class="ruby-identifier">to_s_internal</span>(<span class="ruby-value">10</span>, <span class="ruby-identifier">scale</span>)
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 502</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s_internal</span>(<span class="ruby-identifier">b</span>, <span class="ruby-identifier">sc</span>)
|
15
15
|
<span class="ruby-identifier">sg</span> = <span class="ruby-identifier">sgn</span>
|
16
16
|
<span class="ruby-identifier">i</span> = <span class="ruby-identifier">int_val</span>.<span class="ruby-identifier">abs</span>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 527</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_f</span>
|
15
15
|
<span class="ruby-identifier">divisor</span> = <span class="ruby-identifier">denominator</span>
|
16
16
|
<span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">divisor</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>) <span class="ruby-keyword kw">then</span>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 561</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_i</span>
|
15
15
|
<span class="ruby-identifier">numerator</span>.<span class="ruby-identifier">div</span>(<span class="ruby-identifier">denominator</span>)
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 570</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_ld</span>(<span class="ruby-identifier">prec</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">mode</span> = <span class="ruby-constant">LongDecimal</span><span class="ruby-operator">::</span><span class="ruby-constant">ROUND_HALF_UP</span>)
|
15
15
|
<span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">prec</span>.<span class="ruby-identifier">nil?</span>)
|
16
16
|
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 581</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_bd</span>
|
15
15
|
<span class="ruby-comment cmt"># this operation is probably not used so heavily, so we can live with a</span>
|
16
16
|
<span class="ruby-comment cmt"># string as an intermediate step.</span>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 595</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">denominator</span>
|
15
15
|
<span class="ruby-value">10</span><span class="ruby-operator">**</span><span class="ruby-identifier">scale</span>
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 617</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">int_digits2</span>
|
15
15
|
<span class="ruby-identifier">int_part</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">abs</span>.<span class="ruby-identifier">to_i</span>
|
16
16
|
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">int_part</span>.<span class="ruby-identifier">zero?</span> <span class="ruby-keyword kw">then</span>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 647</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sint_digits10</span>
|
15
15
|
<span class="ruby-keyword kw">if</span> (<span class="ruby-ivar">@digits10</span>.<span class="ruby-identifier">nil?</span>)
|
16
16
|
<span class="ruby-ivar">@digits10</span> = <span class="ruby-constant">LongMath</span>.<span class="ruby-identifier">int_digits10</span>(<span class="ruby-identifier">int_val</span>) <span class="ruby-operator">-</span> <span class="ruby-identifier">scale</span>
|