rubysl-bigdecimal 1.0.0 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 41333a9987e69d300bdf0e97e22079011ba40c5e
4
- data.tar.gz: 02f1483d9986293cadfe6fcb9e1567a5e4c824c5
3
+ metadata.gz: e8aee01bd8b35b34018055abf853ab88ae679b3f
4
+ data.tar.gz: 550826ac7ea321b66c049b6edc8c086c58b787ca
5
5
  SHA512:
6
- metadata.gz: 523d5b1fc0b0249f8447d1feda50be12faef1ee40380a2022ec82f81575b876a73bcfa7965918f823b77be2ee2e77d7d3b3ff6c19d2b98572be0ee8d9e888547
7
- data.tar.gz: 7f0eb82bf50bccbffa147cf89482fd5398bfc68ea44071337271137d58f7b5f4bc5c7d8648c735235cc5b53340371afc9bbcebfe9b872845b1bc21c226063281
6
+ metadata.gz: a8c2b2bb3d238d9ff3833351c44ef7272ce841bdbb39b2b4ed679aeb6b54671f0f337d13f43dae0a3ff10ea35467d1648669dcb35a619b288b0e016d52ba69a2
7
+ data.tar.gz: 7c3118b06a6e2fd74b9f51fdefb211cd3ab68e201a547bf8d40026385a6c1767689bedcc98b6db7a4fd6d9cb30e33da5b035cc3c2bfa0b3803c117a519337a58
@@ -1,8 +1,9 @@
1
1
  language: ruby
2
2
  before_install:
3
+ - rvm use $RVM --install --binary --fuzzy
3
4
  - gem update --system
4
5
  - gem --version
5
6
  - gem install rubysl-bundler
7
+ env:
8
+ - RVM=rbx-nightly-d21 RUBYLIB=lib
6
9
  script: bundle exec mspec spec
7
- rvm:
8
- - rbx-nightly-18mode
data/README.md CHANGED
@@ -1,29 +1,60 @@
1
- # Rubysl::Bigdecimal
2
1
 
3
- TODO: Write a gem description
2
+ Ruby BIGDECIMAL(Variable Precision) extension library.
3
+ Copyright (C) 1999 by Shigeo Kobayashi(shigeo@tinyforest.gr.jp)
4
4
 
5
- ## Installation
5
+ BigDecimal is copyrighted free software by Shigeo Kobayashi <shigeo@tinyforest.gr.jp>.
6
+ You can redistribute it and/or modify it under either the terms of the GPL
7
+ (see COPYING file), or the conditions below:
6
8
 
7
- Add this line to your application's Gemfile:
9
+ 1. You may make and give away verbatim copies of the source form of the
10
+ software without restriction, provided that you duplicate all of the
11
+ original copyright notices and associated disclaimers.
8
12
 
9
- gem 'rubysl-bigdecimal'
13
+ 2. You may modify your copy of the software in any way, provided that
14
+ you do at least ONE of the following:
10
15
 
11
- And then execute:
16
+ a) place your modifications in the Public Domain or otherwise
17
+ make them Freely Available, such as by posting said
18
+ modifications to Usenet or an equivalent medium, or by allowing
19
+ the author to include your modifications in the software.
12
20
 
13
- $ bundle
21
+ b) use the modified software only within your corporation or
22
+ organization.
14
23
 
15
- Or install it yourself as:
24
+ c) rename any non-standard executables so the names do not conflict
25
+ with standard executables, which must also be provided.
16
26
 
17
- $ gem install rubysl-bigdecimal
27
+ d) make other distribution arrangements with the author.
18
28
 
19
- ## Usage
29
+ 3. You may distribute the software in object code or executable
30
+ form, provided that you do at least ONE of the following:
20
31
 
21
- TODO: Write usage instructions here
32
+ a) distribute the executables and library files of the software,
33
+ together with instructions (in the manual page or equivalent)
34
+ on where to get the original distribution.
22
35
 
23
- ## Contributing
36
+ b) accompany the distribution with the machine-readable source of
37
+ the software.
24
38
 
25
- 1. Fork it
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
39
+ c) give non-standard executables non-standard names, with
40
+ instructions on where to get the original software distribution.
41
+
42
+ d) make other distribution arrangements with the author.
43
+
44
+ 4. You may modify and include the part of the software into any other
45
+ software (possibly commercial).
46
+
47
+ 5. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
48
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
49
+ WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
50
+ PURPOSE.
51
+
52
+ * The Author
53
+
54
+ Feel free to send comments and bug reports to the author. Here is the
55
+ author's latest mail address:
56
+
57
+ shigeo@tinyforest.gr.jp
58
+
59
+ -------------------------------------------------------
60
+ created at: Thu Dec 22 1999
@@ -1,4 +1,3 @@
1
- <!-- saved from url=(0022)http://internet.e-mail -->
2
1
  <HTML>
3
2
  <HEAD>
4
3
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html">
@@ -32,18 +31,18 @@ pre
32
31
  <BODY BGCOLOR=#FFFFE0>
33
32
  <H1>BigDecimal(Variable Precision Floating Library for Ruby)</H1>
34
33
  <DIV align="right"><A HREF="./bigdecimal_ja.html">Japanese</A></DIV><BR>
35
- BigDecimal is an extension library for the Ruby interpreter.
36
- Using BigDecimal class, you can obtain any number of significant digits in computation.
34
+ BigDecimal is an extension library for the Ruby interpreter.
35
+ Using BigDecimal class, you can obtain any number of significant digits in computation.
37
36
  For the details about Ruby see:<BR>
38
37
  <UL>
39
38
  <LI><A HREF="http://www.ruby-lang.org/en/">http://www.ruby-lang.org/en/</A>:Official Ruby page(English).</LI>
40
39
  <LI><A HREF="http://kahori.com/ruby/ring/">http://kahori.com/ruby/ring/</A>:Mutually linked pages relating to Ruby(Japanese).
41
40
  </LI>
42
- </UL>
41
+ </UL>
43
42
  NOTE:<BR>
44
43
  This software is provided "AS IS" and without any express or
45
44
  implied warranties,including,without limitation,the implied
46
- warranties of merchantibility and fitness for a particular
45
+ warranties of merchantability and fitness for a particular
47
46
  purpose. For the details,see COPYING and README included in this
48
47
  distribution.
49
48
  <BR>
@@ -63,15 +62,15 @@ NOTE:<BR>
63
62
  <A NAME="#INTRO">
64
63
  <H2>Introduction</H2>
65
64
  Ruby already has builtin (variable length integer number) class Bignum. Using Bignum class,you can obtain
66
- any integer value in magnitude. But, variable length decimal number class is not yet built in.
65
+ any integer value in magnitude. But, variable length decimal number class is not yet built in.
67
66
  This is why I made variable length floating class BigDecimal.
68
67
  Feel free to send any comments or bug reports to me.
69
68
  <A HREF="mailto:shigeo@tinyforest.gr.jp">shigeo@tinyforest.gr.jp</A>
70
- I will try(but can't promise) to fix bugs reported.
69
+ I will try(but can't promise) to fix bugs reported.
71
70
  <hr>
72
71
  <H2>Installation</H2>
73
72
  The Ruby latest version can be downloaded from <A HREF="http://www.ruby-lang.org/en/">Official Ruby page</A>.
74
- Once decompress the downloaded Ruby archive,follow the normal installation procedures according to the
73
+ Once decompress the downloaded Ruby archive,follow the normal installation procedures according to the
75
74
  documents included.
76
75
 
77
76
  <A NAME="#SPEC">
@@ -90,7 +89,7 @@ to create BigDecimal objects,the program would like:<BR>
90
89
  In 32 bits integer system,every 4 digits(in decimal) are computed simultaneously.
91
90
  This means the number of significant digits in BigDecimal is always a multiple of 4.
92
91
  <P>
93
- Some more methods are available in Ruby code (not C code).
92
+ Some more methods are available in Ruby code (not C code).
94
93
  Functions such as sin,cos ...,are in math.rb in bigdecimal directory.
95
94
  To use them,require math.rb as:
96
95
  <CODE><PRE>
@@ -111,11 +110,11 @@ For details,see the util.rb code.
111
110
  a=BigDecimal::new(s[,n]) or<BR>
112
111
  a=BigDecimal(s[,n]) or<BR>
113
112
  where:<BR>
114
- s: Initial value string. Spaces will be ignored. Any unrecognizable character for
113
+ s: Initial value string. Spaces will be ignored. Any unrecognizable character for
115
114
  representing initial value terminates the string.<BR>
116
115
  n: Maximum number of significant digits of a. n must be a Fixnum object.
117
116
  If n is omitted or is equal to 0,then the maximum number of significant digits of a is determined from the length of s.
118
- Actual number of digits handled in computations are usually gretaer than n.<BR>
117
+ Actual number of digits handled in computations are usually greater than n.<BR>
119
118
  n is useful when performing divisions like
120
119
  <CODE><PRE>
121
120
  BigDecimal("1") / BigDecimal("3") # => 0.3333333333 33E0
@@ -141,13 +140,13 @@ f = BigDecimal::mode(BigDecimal::EXCEPTION_ZERODIVIDE,flag)<BR>
141
140
  f = BigDecimal::mode(BigDecimal::EXCEPTION_ALL,flag)<BR>
142
141
  </BLOCKQUOTE>
143
142
  EXCEPTION_NaN controls the execution when computation results to NaN.<BR>
144
- EXCEPTION_INFINITY controls the execution when computation results to Infinity(�}Infinity).<BR>
143
+ EXCEPTION_INFINITY controls the execution when computation results to Infinity.<BR>
145
144
  EXCEPTION_UNDERFLOW controls the execution when computation underflows.<BR>
146
145
  EXCEPTION_OVERFLOW controls the execution when computation overflows.<BR>
147
- EXCEPTION_ZERODIVIDE controls the execution when zero-division occures.<BR>
148
- EXCEPTION_ALL controls the execution for any exception defined occures.<BR>
146
+ EXCEPTION_ZERODIVIDE controls the execution when zero-division occurs.<BR>
147
+ EXCEPTION_ALL controls the execution when any defined exception occurs.<BR>
149
148
  If the flag is true,then the relating exception is thrown.<BR>
150
- No exception is thrown when the flag is false(default) and computation
149
+ No exception is thrown when the flag is false(default) and computation
151
150
  continues with the result:<BR>
152
151
  <BLOCKQUOTE>
153
152
  EXCEPTION_NaN results to NaN<BR>
@@ -160,7 +159,7 @@ EXCEPTION_INFINITY,EXCEPTION_OVERFLOW, and EXCEPTION_ZERODIVIDE are
160
159
  currently the same.<BR>
161
160
  The return value of mode method is the value set.<BR>
162
161
  If nil is specified for the second argument,then current setting is returned.<BR>
163
- Suppose the return value of the mode method is f,then
162
+ Suppose the return value of the mode method is f,then
164
163
  f &amp; BigDecimal::EXCEPTION_NaN !=0 means EXCEPTION_NaN is set to on.
165
164
  <P>
166
165
  <B>[ROUND error control]</B><P>
@@ -181,12 +180,12 @@ where flag must be one of:
181
180
  </TABLE>
182
181
  New rounding mode is returned. If nil is specified for the second argument,then current setting is returned.<BR>
183
182
  The digit location for rounding operation can not be specified by this mode method,
184
- use truncate/round/ceil/floor/add/sub/mult/div mthods for each instance instead.
183
+ use truncate/round/ceil/floor/add/sub/mult/div methods for each instance instead.
185
184
  </BLOCKQUOTE>
186
185
 
187
186
  <LI><B>limit[(n)]</B></LI><BLOCKQUOTE>
188
187
  Limits the maximum digits that the newly created BigDecimal objects can hold never exceed n.
189
- This means the rounding operation specified by BigDecimal.mode is
188
+ This means the rounding operation specified by BigDecimal.mode is
190
189
  performed if necessary.
191
190
  limit returns the value before set if n is nil or is not specified.
192
191
  Zero,the default value,means no upper limit.<BR>
@@ -195,7 +194,7 @@ mf = BigDecimal::limit(n)<BR>
195
194
  </BLOCKQUOTE>
196
195
 
197
196
  <LI><B>double_fig</B></LI><BLOCKQUOTE>
198
- double_fig is a class method which returns the number of digits
197
+ double_fig is a class method which returns the number of digits
199
198
  the Float class can have.
200
199
  <CODE><PRE>
201
200
  p BigDecimal::double_fig # ==> 20 (depends on the CPU etc.)
@@ -291,7 +290,7 @@ returns the maximum integer value (in BigDecimal) which is less than or equal to
291
290
  c = BigDecimal("-1.23456").floor # ==> -2
292
291
  </PRE></CODE>
293
292
 
294
- As shown in the following example,an optional integer argument (n) specifying the position
293
+ As shown in the following example,an optional integer argument (n) specifying the position
295
294
  of the target digit can be given.<BR>
296
295
  If n> 0,then the (n+1)th digit counted from the decimal point in fraction part is processed(resulting number of fraction part digits is less than or equal to n).<BR>
297
296
  If n<0,then the n-th digit counted from the decimal point in integer part is processed(at least n 0's are placed from the decimal point to left).
@@ -309,7 +308,7 @@ returns the minimum integer value (in BigDecimal) which is greater than or equal
309
308
  c = BigDecimal("-1.23456").ceil # ==> -1
310
309
  </PRE></CODE>
311
310
 
312
- As shown in the following example,an optional integer argument (n) specifying the position
311
+ As shown in the following example,an optional integer argument (n) specifying the position
313
312
  of the target digit can be given.<BR>
314
313
  If n>0,then the (n+1)th digit counted from the decimal point in fraction part is processed(resulting number of fraction part digits is less than or equal to n).<BR>
315
314
  If n<0,then the n-th digit counted from the decimal point in integer part is processed(at least n 0's are placed from the decimal point to left).
@@ -321,14 +320,14 @@ If n<0,then the n-th digit counted from the decimal point in integer part is pro
321
320
  </BLOCKQUOTE>
322
321
  <LI><B>round[(n[,b])]</B></LI><BLOCKQUOTE>
323
322
  c = a.round<BR>
324
- round a to the nearest 1(default)�D<BR>
323
+ round a to the nearest 1(default)ÅD<BR>
325
324
  <CODE><PRE>
326
325
  c = BigDecimal("1.23456").round # ==> 1
327
326
  c = BigDecimal("-1.23456").round # ==> -1
328
327
  </PRE></CODE>
329
328
  The rounding operation changes according to BigDecimal::mode(BigDecimal::ROUND_MODE,flag) if specified.
330
329
 
331
- As shown in the following example,an optional integer argument (n) specifying the position
330
+ As shown in the following example,an optional integer argument (n) specifying the position
332
331
  of the target digit can be given.<BR>
333
332
  If n>0,then the (n+1)th digit counted from the decimal point in fraction part is processed(resulting number of fraction part digits is less than or equal to n).<BR>
334
333
  If n<0,then the n-th digit counted from the decimal point in integer part is processed(at least n 0's are placed from the decimal point to left).
@@ -346,8 +345,8 @@ c = BigDecimal::new("1.23356").round(3,BigDecimal::ROUND_HALF_EVEN) # ==> 1.2
346
345
  </BLOCKQUOTE>
347
346
  <LI><B>truncate[(n)]</B></LI><BLOCKQUOTE>
348
347
  c = a.truncate<BR>
349
- truncate a to the nearest 1�D<BR>
350
- As shown in the following example,an optional integer argument (n) specifying the position
348
+ truncate a to the nearest 1ÅD<BR>
349
+ As shown in the following example,an optional integer argument (n) specifying the position
351
350
  of the target digit can be given.<BR>
352
351
  If n>0,then the (n+1)th digit counted from the decimal point in fraction part is processed(resulting number of fraction part digits is less than or equal to n).<BR>
353
352
  If n<0,then the n-th digit counted from the decimal point in integer part is processed(at least n 0's are placed from the decimal point to left).
@@ -374,7 +373,7 @@ converts to string(default results look like "0.xxxxxEn").
374
373
  <CODE><PRE>
375
374
  BigDecimal("1.23456").to_s # ==> "0.123456E1"
376
375
  </PRE></CODE>
377
- If n(>0) is given,then a space is inserted to each of two parts divided by the decimal point
376
+ If n(>0) is given,then a space is inserted to each of two parts divided by the decimal point
378
377
  after every n digits for readability.
379
378
  <CODE><PRE>
380
379
  BigDecimal("0.1234567890123456789").to_s(10) # ==> "0.1234567890 123456789E0"
@@ -391,7 +390,7 @@ BigDecimal("0.1234567890123456789").to_s("+10") # ==> "+0.1234567890 123456789E
391
390
  BigDecimal("-0.1234567890123456789").to_s("10") # ==> "-0.1234567890 123456789E0"
392
391
  </PRE></CODE>
393
392
 
394
- At the end of the string,'E'(or 'e') or 'F'(or 'f') can be specified to change
393
+ At the end of the string,'E'(or 'e') or 'F'(or 'f') can be specified to change
395
394
  number representation.
396
395
  <CODE><PRE>
397
396
  BigDecimal("1234567890.123456789").to_s("E") # ==> "0.1234567890123456789E10"
@@ -409,7 +408,7 @@ means a = 0.xxxxxxx*10**n.
409
408
 
410
409
  <LI><B>precs</B></LI><BLOCKQUOTE>
411
410
  n,m = a.precs <BR>
412
- prec returns number of significant digits (n) and maximum number of
411
+ precs returns number of significant digits (n) and maximum number of
413
412
  significant digits (m) of a.
414
413
  </BLOCKQUOTE>
415
414
 
@@ -439,11 +438,11 @@ a.nan? returns True when a is NaN.
439
438
 
440
439
  </BLOCKQUOTE>
441
440
  <LI><B>infinite?</B></LI><BLOCKQUOTE>
442
- a.infinite? returns 1 when a is +��,-1 when a is -��, nil otherwise.
441
+ a.infinite? returns 1 when a is Infinity, -1 when a is -Infinity, nil otherwise.
443
442
 
444
443
  </BLOCKQUOTE>
445
444
  <LI><B>finite?</B></LI><BLOCKQUOTE>
446
- a.finite? returns true when a is neither �� nor NaN.
445
+ a.finite? returns true when a is neither Infinity nor NaN.
447
446
  </BLOCKQUOTE>
448
447
 
449
448
  <LI><B>zero?</B></LI><BLOCKQUOTE>
@@ -474,7 +473,7 @@ p a=BigDecimal::new("3.14",10)<BR>
474
473
  should produce output like "#&lt;0x112344:'0.314E1',4(12)%gt;".
475
474
  where "0x112344" is the address,
476
475
  '0.314E1' is the value,4 is the number of the significant digits,
477
- and 12 is the maximum number of the significant digits
476
+ and 12 is the maximum number of the significant digits
478
477
  the object can hold.
479
478
  </BLOCKQUOTE>
480
479
 
@@ -526,14 +525,14 @@ same as ==,used in case statement.
526
525
  <DT> 1.Both A and B are BigDecimal objects</DT>
527
526
  <DD> A op B is normally performed.</DD>
528
527
  <DT> 2.A is the BigDecimal object but B is other than BigDecimal object</DT>
529
- <DD> Operation is performed,after B is translated to correcponding BigDecimal object(because BigDecimal supports coerce method).</DD>
528
+ <DD> Operation is performed,after B is translated to corresponding BigDecimal object(because BigDecimal supports coerce method).</DD>
530
529
  <DT> 3.A is not the BigDecimal object but B is BigDecimal object</DT>
531
- <DD>If A has coerce mthod,then B will translate A to corresponding
530
+ <DD>If A has coerce method,then B will translate A to corresponding
532
531
  BigDecimal object and the operation is performed,otherwise an error occures.</DD>
533
532
  </DL>
534
533
 
535
534
  String is not translated to BigDecimal in default.
536
- Uncomment /* #define ENABLE_NUMERIC_STRING */ in bigdecimal.c, compile and install
535
+ Uncomment /* #define ENABLE_NUMERIC_STRING */ in bigdecimal.c, compile and install
537
536
  again if you want to enable string to BigDecimal conversion.
538
537
  Translation stops without error at the character representing non digit.
539
538
  For instance,"10XX" is translated to 10,"XXXX" is translated to 0.<BR>
@@ -564,7 +563,7 @@ and define coerce method within the new class.<BR>
564
563
  Infinite numbers and NaN can be represented by string writing "+Infinity"(or "Infinity"),"-Infinity",and "NaN" respectively in your program.
565
564
  Infinite numbers can be obtained by 1.0/0.0(=Infinity) or -1.0/0.0(=-Infinity).
566
565
  <BR><BR>
567
- NaN(Not a number) can be obtained by undefined computation like 0.0/0.0
566
+ NaN(Not a number) can be obtained by undefined computation like 0.0/0.0
568
567
  or Infinity-Infinity.
569
568
  Any computation including NaN results to NaN.
570
569
  Comparisons with NaN never become true,including comparison with NaN itself.
@@ -573,7 +572,7 @@ Zero has two different variations as +0.0 and -0.0.
573
572
  But,still, +0.0==-0.0 is true.
574
573
  <BR><BR>
575
574
  Computation results including Infinity,NaN,+0.0 or -0.0 become complicated.
576
- Run following program and comfirm the results.
575
+ Run following program and confirm the results.
577
576
  Send me any incorrect result if you find.
578
577
 
579
578
  <CODE><PRE>
@@ -603,12 +602,9 @@ where 'x' is any digit representing mantissa(kept in the array frac[]),
603
602
  BASE is base value(=10000 in 32 bit integer system),
604
603
  and n is the exponent value.<BR>
605
604
  Larger BASE value enables smaller size of the array frac[],and increases computation speed.
606
- The value of BASE is defined ind VpInit(). In 32 bit integer system,this value is
607
- 10000. In 64 bit integer system,the value becomes larger.
608
- BigDecimal has not yet been compiled and tested on 64 bit integer system.
609
- It will be very nice if anyone try to run BigDecimal on 64 bit system and
610
- inform me the results.
611
- When BASE is 10000,an element of the array frac[] can have vale of from 0 to 9999.
605
+ The value of BASE is defined ind VpInit(). In 32 bit integer system, this value is
606
+ 10000. In 64 bit integer system, the value is 1000000000.
607
+ When BASE is 10000,an element of the array frac[] can have value of from 0 to 9999.
612
608
  (up to 4 digits).<BR>
613
609
  The structure Real is defined in bigdecimal.h as:<BR>
614
610
  <CODE><PRE>
@@ -626,7 +622,7 @@ The structure Real is defined in bigdecimal.h as:<BR>
626
622
  /* -3 : -Infinity */
627
623
  unsigned short flag; /* Control flag */
628
624
  int exponent; /* Exponent value(0.xxxx*BASE**exponent) */
629
- unsigned long frac[1]; /* An araay holding mantissa(Variable) */
625
+ unsigned long frac[1]; /* An array holding mantissa(Variable) */
630
626
  } Real;
631
627
  </CODE></PRE>
632
628
  The decimal value 1234.56784321 is represented as(BASE=10000):<BR>
@@ -634,7 +630,7 @@ The decimal value 1234.56784321 is represented as(BASE=10000):<BR>
634
630
  0.1234 5678 4321*(10000)**1
635
631
  </PRE>
636
632
  where frac[0]=1234,frac[1]=5678,frac[2]=4321,
637
- Prec=3,sign=2,exponent=1. MaxPrec can be any value greater than or equal to
633
+ Prec=3,sign=2,exponent=1. MaxPrec can be any value greater than or equal to
638
634
  Prec.
639
635
  <hr>
640
636
 
@@ -661,29 +657,29 @@ The reason why I adopted decimal number representation for BigDecimal is:<BR>
661
657
  end
662
658
  </PRE></CODE>
663
659
 
664
- If the internal representation is binary,translation from decimal to
660
+ If the internal representation is binary,translation from decimal to
665
661
  binary is required and the translation error is inevitable.
666
662
  For example, 0.1 can not exactly be represented in binary.<BR>
667
663
  0.1 => b1*2**(-1)+b1*2**(-2)+b3*2**(-3)+b4*2**(-4)....<BR>
668
664
  where b1=0,b2=0,b3=0,b4=1...<BR>
669
665
  bn(n=1,2,3,...) is infinite series of digit with value of 0 or 1,
670
666
  and rounding operation is necessary but where we should round the series ?
671
- Of cource,exact "0.1" is printed if the rouding operation is properly done,
667
+ Of course, exact "0.1" is printed if the rounding operation is properly done,
672
668
  <DT>Significant digit we can have is automatically determined
673
669
  <DD>In binary representation,0.1 can not be represented in finite series of digit.
674
670
 
675
671
  But we only need one element(frac[0]=1) in decimal representation.
676
- This means that we can always determine the size of the array frac[] in Real
672
+ This means that we can always determine the size of the array frac[] in Real
677
673
  structure.
678
674
  </DL>
679
675
 
680
676
  <H3>Disadvantage of decimal representation</H3>
681
- Because most computers have no internal decimal representaion.
677
+ Because most computers have no internal decimal representation.
682
678
  Once you use BigDecimal,you need to keep using it without
683
679
  considering computation cost if exact computation is required.
684
680
 
685
681
  <H4>Which is the first input?</H4>
686
- Because most people uses decimal notatin for numeric data representation,
682
+ Because most people uses decimal notation for numeric data representation,
687
683
  BigDecimal can handle numeric data without loss of translation error.
688
684
  <hr>
689
685
 
@@ -693,23 +689,23 @@ For the fundamental arithmetics such as addition,subtraction,
693
689
  multiplication,and division,I prepared 2 group of methods<BR>
694
690
 
695
691
  <H3>1. +,-,*,/</H3>
696
- For the operation + - * /,you can not specify the resulting
692
+ For the operation + - * /,you can not specify the resulting
697
693
  number of significant digits.<BR>
698
694
  Resulting number of significant digits are defined as:<BR>
699
- 1.1 For *,resulting number of significant digits is the sum of the
700
- significant digits of both side of the operator. For / ,resulting number of significant digits is the sum of the
695
+ 1.1 For *,resulting number of significant digits is the sum of the
696
+ significant digits of both side of the operator. For / ,resulting number of significant digits is the sum of the
701
697
  maximum significant digits of both side of the operator.<BR>
702
698
  1.2 For + and -,resulting number of significant digits is determined so that
703
699
  no round operation is needed. <br>
704
- For example, c has more than 100 siginificant digits if c is computed as:<BR>
700
+ For example, c has more than 100 significant digits if c is computed as:<BR>
705
701
  c = 0.1+0.1*10**(-100)<br>
706
702
  <BR>
707
703
  As +,-,and * are always exact(no round operation is performed unless BigDecimal.limit is specified),
708
- which means more momories are required to keep computation results.
704
+ which means more memory is required to keep computation results.
709
705
  But,the division such as c=1.0/3.0 will always be rounded.<BR>
710
706
 
711
707
  <H3>2. add,sub,mult,div</H3>
712
- The length of the significant digits obtained from +,-,*,/
708
+ The length of the significant digits obtained from +,-,*,/
713
709
  is always defined by that of right and left side of the operator.
714
710
  To specify the length of the significant digits by your self,
715
711
  use methos add,sub,mult,div.
@@ -728,8 +724,8 @@ decimal point.
728
724
 
729
725
 
730
726
  <H3>4. Example</H3>
731
- Following example compute the ratio of the circumference of a circle to
732
- its dirmeter(pi=3.14159265358979....) using J.Machin's formula.
727
+ Following example compute the ratio of the circumference of a circle to
728
+ its diameter(pi=3.14159265358979....) using J.Machin's formula.
733
729
  <BR><BR>
734
730
  <CODE><PRE>
735
731
  #!/usr/local/bin/ruby
@@ -750,7 +746,7 @@ def big_pi(sig) # sig: Number of significant figures
750
746
  k = BigDecimal::new("1")
751
747
  w = BigDecimal::new("1")
752
748
  t = BigDecimal::new("-80")
753
- while (u.nonzero? && u.exponent >= exp)
749
+ while (u.nonzero? && u.exponent >= exp)
754
750
  t = t*m25
755
751
  u = t.div(k,sig)
756
752
  pi = pi + u