long-decimal 0.00.16 → 0.00.17
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 +16 -15
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/doc/classes/LongDecimal.html +15 -8
- data/doc/classes/LongDecimal.src/M000041.html +3 -2
- 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 -3
- 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 +7 -3
- 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/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/M000061.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 +1 -1
- 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 +30 -4
- data/doc/classes/LongDecimal.src/M000090.html +1 -1
- data/doc/classes/LongDecimal.src/M000091.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/M000096.html +1 -1
- data/doc/classes/LongDecimal.src/M000097.html +1 -1
- data/doc/classes/LongDecimal.src/M000098.html +1 -1
- data/doc/classes/LongDecimal.src/M000099.html +1 -1
- data/doc/classes/LongDecimalBase.html +58 -57
- data/doc/classes/LongDecimalBase.src/M000102.html +4 -4
- data/doc/classes/LongDecimalBase.src/M000103.html +4 -4
- data/doc/classes/LongDecimalBase.src/M000104.html +4 -4
- data/doc/classes/LongDecimalBase.src/M000105.html +4 -4
- data/doc/classes/LongDecimalBase.src/M000106.html +4 -4
- data/doc/classes/LongDecimalBase.src/M000107.html +18 -0
- data/doc/classes/LongDecimalBase.src/M000110.html +9 -5
- data/doc/classes/LongDecimalBase.src/M000111.html +5 -4
- data/doc/classes/LongDecimalBase.src/M000112.html +18 -0
- data/doc/classes/LongDecimalQuot.html +18 -13
- 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 +3 -3
- data/doc/classes/LongDecimalQuot.src/M000012.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000013.html +1 -1
- 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 +35 -2
- data/doc/classes/LongDecimalQuot.src/M000024.html +20 -4
- data/doc/classes/LongDecimalQuot.src/M000025.html +1 -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/M000032.html +1 -1
- data/doc/classes/LongDecimalQuot.src/M000033.html +1 -1
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.html +5 -5
- data/doc/classes/LongDecimalRoundingMode/RoundingModeClass.src/M000137.html +22 -0
- data/doc/classes/LongMath.html +135 -116
- data/doc/classes/LongMath.src/M000113.html +5 -4
- data/doc/classes/LongMath.src/M000114.html +4 -4
- data/doc/classes/LongMath.src/M000115.html +4 -5
- data/doc/classes/LongMath.src/M000116.html +5 -4
- data/doc/classes/LongMath.src/M000117.html +4 -18
- data/doc/classes/LongMath.src/M000118.html +14 -14
- data/doc/classes/LongMath.src/M000119.html +18 -5
- data/doc/classes/LongMath.src/M000120.html +5 -29
- data/doc/classes/LongMath.src/M000121.html +29 -5
- data/doc/classes/LongMath.src/M000122.html +5 -56
- data/doc/classes/LongMath.src/M000123.html +54 -19
- data/doc/classes/LongMath.src/M000124.html +20 -35
- data/doc/classes/LongMath.src/M000125.html +31 -27
- data/doc/classes/LongMath.src/M000126.html +32 -8
- data/doc/classes/LongMath.src/M000127.html +8 -13
- data/doc/classes/LongMath.src/M000128.html +13 -82
- data/doc/classes/LongMath.src/M000129.html +79 -4
- data/doc/classes/LongMath.src/M000130.html +4 -14
- data/doc/classes/LongMath.src/M000131.html +4 -14
- data/doc/classes/LongMath.src/M000132.html +13 -148
- data/doc/classes/LongMath.src/M000133.html +14 -8
- data/doc/classes/LongMath.src/M000134.html +127 -3
- data/doc/classes/LongMath.src/M000135.html +25 -0
- data/doc/classes/LongMath.src/M000136.html +42 -0
- data/doc/classes/Numeric.html +5 -2
- data/doc/classes/Numeric.src/M000100.html +8 -3
- data/doc/classes/Rational.html +158 -0
- data/doc/classes/Rational.src/M000101.html +23 -0
- data/doc/created.rid +1 -1
- data/doc/dot/f_0.dot +9 -0
- data/doc/dot/f_0.png +0 -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_class_index.html +1 -0
- data/doc/fr_method_index.html +56 -54
- data/lib/long-decimal.rb +147 -29
- data/test/testlongdecimal.rb +58 -5
- data/version.rb +1 -1
- metadata +10 -3
- data/doc/files/lib/long-decimal_rb.html +0 -187
data/README
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
Version
|
2
2
|
-------
|
3
3
|
|
4
|
-
This version ($Name:
|
5
|
-
previous pre-alpha-0.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
This version ($Name: PRE_ALPHA_0_17 $) is functionally almost identical with the
|
5
|
+
previous pre-alpha-0.16. The method to_ld() now supports optional
|
6
|
+
parameters to provide desired number of digits after the decimal point
|
7
|
+
and rounding_mode for conversion. Some tests and comments have been
|
8
|
+
added. The documentation-tar.gz is no longer included, because the
|
9
|
+
documentation tar.gz-files of previous versions were hardly downloaded
|
10
|
+
and because it is possible to obtain the documentation from the
|
11
|
+
gem-file or from the source-file.
|
10
12
|
|
11
13
|
It could be observed that gem-installation, as described below, fails
|
12
14
|
on Windows 2000 with ruby 1.8.2, but works on Linux with ruby 1.8.4
|
@@ -29,7 +31,7 @@ ruby 1.8.4 and has been observed to fail on Windows 2000)
|
|
29
31
|
|
30
32
|
1. Using ruby-gems (preferred)
|
31
33
|
- download the newest gem-file from long-decimal project at rubyforge
|
32
|
-
which can be found by
|
34
|
+
which can be found by
|
33
35
|
http://rubyforge.org/projects/long-decimal/ -> Files
|
34
36
|
( http://rubyforge.org/frs/?group_id=1334 )
|
35
37
|
- open a shell window
|
@@ -40,7 +42,7 @@ ruby 1.8.4 and has been observed to fail on Windows 2000)
|
|
40
42
|
[remark: currently rubyforge does not publish long-decimal directly
|
41
43
|
as gem, so you can't use gem to download, but you have to
|
42
44
|
download the gem-file manually first and then use gem only
|
43
|
-
to install it]
|
45
|
+
to install it]
|
44
46
|
|
45
47
|
- Usage from your ruby-programs:
|
46
48
|
require "rubygems"
|
@@ -50,22 +52,22 @@ ruby 1.8.4 and has been observed to fail on Windows 2000)
|
|
50
52
|
$RUBY_DIR/gems/$RUBY_VERSION/doc/long-decimal-$LONG_DECIMAL_VERSION/rdoc/index.html
|
51
53
|
where $RUBY_DIR is the directory containing your ruby-installation,
|
52
54
|
usually /usr/lib/ruby or /usr/local/lib/ruby on
|
53
|
-
Linux/Unix-systems.
|
55
|
+
Linux/Unix-systems.
|
54
56
|
$RUBY_VERSION is the major version of your Ruby, like 1.8
|
55
57
|
$LONG_DECIMAL_VERSION is the version of long-decimal that you
|
56
|
-
have installed, like 0.00.
|
58
|
+
have installed, like 0.00.17
|
57
59
|
on my machine that would be
|
58
|
-
/usr/local/lib/ruby/gems/1.8/doc/long-decimal-0.00.
|
60
|
+
/usr/local/lib/ruby/gems/1.8/doc/long-decimal-0.00.17/rdoc/index.html
|
59
61
|
|
60
62
|
2. Installing from the sources (it is preferred to use the gem-installation)
|
61
63
|
- download the newest source-tar.gz-file from long-decimal project at rubyforge
|
62
|
-
which can be found by
|
64
|
+
which can be found by
|
63
65
|
http://rubyforge.org/projects/long-decimal/ -> Files
|
64
66
|
( http://rubyforge.org/frs/?group_id=1334 )
|
65
67
|
- open a shell window
|
66
68
|
cd to the directory where you have downloaded the gem-file
|
67
69
|
unpack the file using tar
|
68
|
-
tar xfzvv long-decimal-pre-alpha-
|
70
|
+
tar xfzvv long-decimal-pre-alpha-0_17.tar.gz
|
69
71
|
cd long-decimal
|
70
72
|
- now you can use rake for several operations
|
71
73
|
- rake test
|
@@ -81,8 +83,7 @@ ruby 1.8.4 and has been observed to fail on Windows 2000)
|
|
81
83
|
gem install long-decimal
|
82
84
|
|
83
85
|
3. The documentation can be created from the sources. It is contained
|
84
|
-
in the gem-file.
|
85
|
-
tar.gz-file.
|
86
|
+
in the gem-file.
|
86
87
|
|
87
88
|
License
|
88
89
|
-------
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# Rakefile for long-decimal project
|
3
3
|
#
|
4
4
|
# CVS-ID: $Header: /var/cvs/long-decimal/long-decimal/Rakefile,v 1.2 2006/03/18 08:32:02 bk1 Exp $
|
5
|
-
# CVS-Label: $Name:
|
5
|
+
# CVS-Label: $Name: PRE_ALPHA_0_17 $
|
6
6
|
# Author: $Author: bk1 $ (Karl Brodowsky)
|
7
7
|
#
|
8
8
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.00.
|
1
|
+
0.00.17
|
@@ -87,6 +87,7 @@
|
|
87
87
|
<area shape="RECT" coords="6,293,120,341" href="LongDecimalQuot.html" alt="LongDecimalQuot">
|
88
88
|
<area shape="RECT" coords="144,293,238,341" href="LongDecimal.html" alt="LongDecimal">
|
89
89
|
<area shape="RECT" coords="43,101,115,149" href="Numeric.html" alt="Numeric">
|
90
|
+
<area shape="RECT" coords="267,5,339,53" href="Rational.html" alt="Rational">
|
90
91
|
<area shape="RECT" coords="246,187,339,233" href="LongMath.html" alt="LongMath">
|
91
92
|
<area shape="RECT" coords="128,68,304,160" href="LongDecimalRoundingMode.html" alt="LongDecimalRoundingMode">
|
92
93
|
</map>
|
@@ -203,7 +204,7 @@ position of the decimal point.
|
|
203
204
|
LongDecimals can be seen as a fraction with its int_val as its numerator
|
204
205
|
Please observe that there may be common factors of numerator and
|
205
206
|
denominator in case of <a href="LongDecimal.html">LongDecimal</a>, which
|
206
|
-
does not occur in case of Rational
|
207
|
+
does not occur in case of <a href="Rational.html">Rational</a>
|
207
208
|
|
208
209
|
</td>
|
209
210
|
</tr>
|
@@ -472,8 +473,8 @@ integer, the power is a <a href="LongDecimalQuot.html">LongDecimalQuot</a>
|
|
472
473
|
as would result by successive division, but with the same scale as the
|
473
474
|
positive power would get. Explicit rounding is needed to convert into a <a
|
474
475
|
href="LongDecimal.html">LongDecimal</a> again in all other cases, self is
|
475
|
-
converted into a Rational prior to applying
|
476
|
-
Float as power.
|
476
|
+
converted into a <a href="Rational.html">Rational</a> prior to applying
|
477
|
+
power, usually resulting in a Float as power.
|
477
478
|
</p>
|
478
479
|
</div>
|
479
480
|
</div>
|
@@ -755,8 +756,8 @@ LongDecimals can be seen as a fraction with a power of 10 as denominator
|
|
755
756
|
for compatibility with other numeric classes this method is included,
|
756
757
|
returning 10**scale. Please observe that there may be common factors of
|
757
758
|
numerator and denominator in case of <a
|
758
|
-
href="LongDecimal.html">LongDecimal</a>, which does not occur in case of
|
759
|
-
Rational
|
759
|
+
href="LongDecimal.html">LongDecimal</a>, which does not occur in case of <a
|
760
|
+
href="Rational.html">Rational</a>
|
760
761
|
</p>
|
761
762
|
</div>
|
762
763
|
</div>
|
@@ -1037,8 +1038,8 @@ usually not an decrement by 1, but by 1/10**scale.
|
|
1037
1038
|
|
1038
1039
|
<div class="method-description">
|
1039
1040
|
<p>
|
1040
|
-
divide self by other and return result as
|
1041
|
-
calculations.
|
1041
|
+
divide self by other and return result as <a
|
1042
|
+
href="Rational.html">Rational</a>, if other allowed exact calculations.
|
1042
1043
|
</p>
|
1043
1044
|
</div>
|
1044
1045
|
</div>
|
@@ -1272,13 +1273,15 @@ self is actually an integer.
|
|
1272
1273
|
<div class="method-heading">
|
1273
1274
|
<a href="LongDecimal.src/M000049.html" target="Code" class="method-signature"
|
1274
1275
|
onclick="popupCode('LongDecimal.src/M000049.html');return false;">
|
1275
|
-
<span class="method-name">to_ld</span><span class="method-args">()</span>
|
1276
|
+
<span class="method-name">to_ld</span><span class="method-args">(prec = nil, mode = LongDecimal::ROUND_HALF_UP)</span>
|
1276
1277
|
</a>
|
1277
1278
|
</div>
|
1278
1279
|
|
1279
1280
|
<div class="method-description">
|
1280
1281
|
<p>
|
1281
1282
|
convert self into <a href="LongDecimal.html">LongDecimal</a> (returns self)
|
1283
|
+
optional first argument gives the precision for the desired result optional
|
1284
|
+
second argument gives the rouding mode
|
1282
1285
|
</p>
|
1283
1286
|
</div>
|
1284
1287
|
</div>
|
@@ -1295,6 +1298,10 @@ convert self into <a href="LongDecimal.html">LongDecimal</a> (returns self)
|
|
1295
1298
|
|
1296
1299
|
<div class="method-description">
|
1297
1300
|
<p>
|
1301
|
+
convert self into String, which is the decimal representation. Use trailing
|
1302
|
+
zeros, if int_val has them.
|
1303
|
+
</p>
|
1304
|
+
<p>
|
1298
1305
|
optional parameter shown_scale is the number of digits after the decimal
|
1299
1306
|
point. Defaults to the scale of self. optional parameter mode ist the
|
1300
1307
|
rounding mode to be applied. Defaults to ROUND_UNNECESSARY, in which case
|
@@ -45,7 +45,6 @@
|
|
45
45
|
<span class="ruby-identifier">denom</span> <span class="ruby-operator">/=</span> <span class="ruby-value">5</span> <span class="ruby-operator">**</span> <span class="ruby-identifier">mul_5</span>
|
46
46
|
<span class="ruby-identifier">iscale2</span> = <span class="ruby-constant">Math</span>.<span class="ruby-identifier">log10</span>(<span class="ruby-identifier">denom</span>).<span class="ruby-identifier">ceil</span>
|
47
47
|
<span class="ruby-identifier">scale</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">iscale2</span>
|
48
|
-
<span class="ruby-comment cmt"># int_val = (x * 10 ** scale).to_i</span>
|
49
48
|
<span class="ruby-identifier">int_val</span> = (<span class="ruby-identifier">x</span> <span class="ruby-operator">*</span> <span class="ruby-value">10</span> <span class="ruby-operator">**</span> (<span class="ruby-identifier">iscale2</span><span class="ruby-operator">+</span><span class="ruby-identifier">iscale</span>)).<span class="ruby-identifier">to_i</span>
|
50
49
|
|
51
50
|
<span class="ruby-keyword kw">else</span>
|
@@ -90,6 +89,8 @@
|
|
90
89
|
<span class="ruby-identifier">num_frac</span> = <span class="ruby-value str">""</span>
|
91
90
|
<span class="ruby-keyword kw">end</span>
|
92
91
|
|
92
|
+
<span class="ruby-comment cmt"># handle optional e-part of floating point number represented as</span>
|
93
|
+
<span class="ruby-comment cmt"># string</span>
|
93
94
|
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">num_exp</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">num_exp</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword kw">then</span>
|
94
95
|
<span class="ruby-identifier">num_exp</span> = <span class="ruby-value str">"0"</span>
|
95
96
|
<span class="ruby-keyword kw">end</span>
|
@@ -101,7 +102,7 @@
|
|
101
102
|
<span class="ruby-identifier">int_val</span> = <span class="ruby-operator">-</span><span class="ruby-identifier">int_val</span>
|
102
103
|
<span class="ruby-keyword kw">end</span>
|
103
104
|
<span class="ruby-keyword kw">end</span>
|
104
|
-
<span class="ruby-ivar">@scale</span>
|
105
|
+
<span class="ruby-ivar">@scale</span> = <span class="ruby-identifier">scale</span>
|
105
106
|
<span class="ruby-ivar">@int_val</span> = <span class="ruby-identifier">int_val</span>
|
106
107
|
|
107
108
|
<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 349</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 379</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 418</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>)
|
@@ -25,9 +25,7 @@
|
|
25
25
|
<span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-value str">"base must be integer between 2 and 36"</span>
|
26
26
|
<span class="ruby-keyword kw">end</span>
|
27
27
|
<span class="ruby-identifier">quot</span> = (<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">move_point_right</span>(<span class="ruby-identifier">scale</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">base</span> <span class="ruby-operator">**</span> <span class="ruby-identifier">shown_scale</span>) <span class="ruby-operator">/</span> <span class="ruby-value">10</span> <span class="ruby-operator">**</span> <span class="ruby-identifier">scale</span>
|
28
|
-
<span class="ruby-comment cmt"># p(quot)</span>
|
29
28
|
<span class="ruby-identifier">rounded</span> = <span class="ruby-identifier">quot</span>.<span class="ruby-identifier">round_to_scale</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">mode</span>)
|
30
|
-
<span class="ruby-comment cmt"># p(rounded)</span>
|
31
29
|
<span class="ruby-identifier">rounded</span>.<span class="ruby-identifier">to_s_internal</span>(<span class="ruby-identifier">base</span>, <span class="ruby-identifier">shown_scale</span>)
|
32
30
|
<span class="ruby-keyword kw">end</span>
|
33
31
|
<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 441</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 448</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 473</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 503</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,9 +10,13 @@
|
|
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
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_ld</span>
|
15
|
-
<span class="ruby-keyword kw">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/long-decimal.rb, line 512</span>
|
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
|
+
<span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">prec</span>.<span class="ruby-identifier">nil?</span>)
|
16
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>
|
17
|
+
<span class="ruby-keyword kw">else</span>
|
18
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">round_to_scale</span>(<span class="ruby-identifier">prec</span>, <span class="ruby-identifier">mode</span>)
|
19
|
+
<span class="ruby-keyword kw">end</span>
|
16
20
|
<span class="ruby-keyword kw">end</span></pre>
|
17
21
|
</body>
|
18
22
|
</html>
|
@@ -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 523</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 537</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 559</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 582</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">int_digits10</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 619</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">equalize_scale</span>(<span class="ruby-identifier">other</span>)
|
15
15
|
<span class="ruby-identifier">o</span>, <span class="ruby-identifier">s</span> = <span class="ruby-identifier">coerce</span>(<span class="ruby-identifier">other</span>)
|
16
16
|
<span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">s</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">LongDecimal</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 640</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">anti_equalize_scale</span>(<span class="ruby-identifier">other</span>)
|
15
15
|
<span class="ruby-identifier">o</span>, <span class="ruby-identifier">s</span> = <span class="ruby-identifier">coerce</span>(<span class="ruby-identifier">other</span>)
|
16
16
|
<span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">s</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">LongDecimal</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 658</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">succ</span>
|
15
15
|
<span class="ruby-constant">LongDecimal</span>(<span class="ruby-identifier">int_val</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</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 669</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pred</span>
|
15
15
|
<span class="ruby-constant">LongDecimal</span>(<span class="ruby-identifier">int_val</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</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 676</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">inc!</span>
|
15
15
|
<span class="ruby-ivar">@int_val</span> <span class="ruby-operator">+=</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 683</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dec!</span>
|
15
15
|
<span class="ruby-ivar">@int_val</span> <span class="ruby-operator">-=</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 690</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unit</span>
|
15
15
|
<span class="ruby-constant">LongDecimal</span>(<span class="ruby-value">1</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 698</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">-@</span>
|
15
15
|
<span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">zero?</span> <span class="ruby-keyword kw">then</span>
|
16
16
|
<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 714</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">+</span>(<span class="ruby-identifier">other</span>)
|
15
15
|
<span class="ruby-identifier">s</span>, <span class="ruby-identifier">o</span> = <span class="ruby-identifier">equalize_scale</span>(<span class="ruby-identifier">other</span>)
|
16
16
|
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">LongDecimal</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 731</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">-</span>(<span class="ruby-identifier">other</span>)
|
15
15
|
<span class="ruby-identifier">s</span>, <span class="ruby-identifier">o</span> = <span class="ruby-identifier">equalize_scale</span>(<span class="ruby-identifier">other</span>)
|
16
16
|
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">LongDecimal</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 748</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-operator">*</span>(<span class="ruby-identifier">other</span>)
|
15
15
|
<span class="ruby-identifier">o</span>, <span class="ruby-identifier">s</span> = <span class="ruby-identifier">coerce</span>(<span class="ruby-identifier">other</span>)
|
16
16
|
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">LongDecimal</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 761</span>
|
14
14
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">divide</span>(<span class="ruby-identifier">other</span>, <span class="ruby-identifier">rounding_mode</span>)
|
15
15
|
<span class="ruby-identifier">divide_s</span>(<span class="ruby-identifier">other</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">rounding_mode</span>)
|
16
16
|
<span class="ruby-keyword kw">end</span></pre>
|