summaryrefslogtreecommitdiff log msg author committer range
path: root/ext/bigdecimal
diff options
 context: 12345678910152025303540 space: includeignore mode: unifiedssdiffstat only
Diffstat (limited to 'ext/bigdecimal')
-rw-r--r--ext/bigdecimal/bigdecimal_en.html66
-rw-r--r--ext/bigdecimal/bigdecimal_ja.html12
-rw-r--r--ext/bigdecimal/lib/bigdecimal/jacobian.rb2
-rw-r--r--ext/bigdecimal/lib/bigdecimal/util.rb6
5 files changed, 44 insertions, 44 deletions
 diff --git a/ext/bigdecimal/README b/ext/bigdecimal/READMEindex a233f47..ae65b01 100644--- a/ext/bigdecimal/README+++ b/ext/bigdecimal/README@@ -51,7 +51,7 @@ You can redistribute it and/or modify it under either the terms of the GPL * The Author -Feel free to send comments and bug reports to the author. Here is the +Feel free to send comments and bug reports to the author. Here is the author's latest mail address: shigeo@tinyforest.gr.jpdiff --git a/ext/bigdecimal/bigdecimal_en.html b/ext/bigdecimal/bigdecimal_en.htmlindex 82acd2a..afaf8ec 100644--- a/ext/bigdecimal/bigdecimal_en.html+++ b/ext/bigdecimal/bigdecimal_en.html@@ -31,14 +31,14 @@ pre

BigDecimal(Variable Precision Floating Library for Ruby)

Japanese

-BigDecimal is an extension library for the Ruby interpreter. -Using BigDecimal class, you can obtain any number of significant digits in computation. +BigDecimal is an extension library for the Ruby interpreter.+Using BigDecimal class, you can obtain any number of significant digits in computation. For the details about Ruby see:
+ NOTE:
This software is provided "AS IS" and without any express or implied warranties,including,without limitation,the implied@@ -62,15 +62,15 @@ NOTE:

Introduction

Ruby already has builtin (variable length integer number) class Bignum. Using Bignum class,you can obtain- any integer value in magnitude. But, variable length decimal number class is not yet built in. + any integer value in magnitude. But, variable length decimal number class is not yet built in. This is why I made variable length floating class BigDecimal. Feel free to send any comments or bug reports to me.
shigeo@tinyforest.gr.jp-I will try(but can't promise) to fix bugs reported. +I will try(but can't promise) to fix bugs reported.

Installation

In 32 bits integer system,every 4 digits(in decimal) are computed simultaneously. This means the number of significant digits in BigDecimal is always a multiple of 4.

-Some more methods are available in Ruby code (not C code). +Some more methods are available in Ruby code (not C code). Functions such as sin,cos ...,are in math.rb in bigdecimal directory. To use them,require math.rb as:

@@ -110,7 +110,7 @@ For details,see the util.rb code. a=BigDecimal::new(s[,n]) or
a=BigDecimal(s[,n]) or
where:
-s: Initial value string. Spaces will be ignored. Any unrecognizable character for +s: Initial value string. Spaces will be ignored. Any unrecognizable character for representing initial value terminates the string.
n: Maximum number of significant digits of a. n must be a Fixnum object. 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.@@ -146,7 +146,7 @@ EXCEPTION_OVERFLOW controls the execution when computation overflows.
EXCEPTION_ZERODIVIDE controls the execution when zero-division occurs.
EXCEPTION_ALL controls the execution when any defined exception occurs.
If the flag is true,then the relating exception is thrown.
-No exception is thrown when the flag is false(default) and computation +No exception is thrown when the flag is false(default) and computation continues with the result:
EXCEPTION_NaN results to NaN
@@ -159,7 +159,7 @@ EXCEPTION_INFINITY,EXCEPTION_OVERFLOW, and EXCEPTION_ZERODIVIDE are currently the same.
The return value of mode method is the value set.
If nil is specified for the second argument,then current setting is returned.
-Suppose the return value of the mode method is f,then +Suppose the return value of the mode method is f,then f & BigDecimal::EXCEPTION_NaN !=0 means EXCEPTION_NaN is set to on.

[ROUND error control]

• limit[(n)]
• Limits the maximum digits that the newly created BigDecimal objects can hold never exceed n.-This means the rounding operation specified by BigDecimal.mode is +This means the rounding operation specified by BigDecimal.mode is performed if necessary. limit returns the value before set if n is nil or is not specified. Zero,the default value,means no upper limit.
@@ -194,7 +194,7 @@ mf = BigDecimal::limit(n)
• double_fig
• -double_fig is a class method which returns the number of digits +double_fig is a class method which returns the number of digits the Float class can have.
p BigDecimal::double_fig  # ==> 20 (depends on the CPU etc.)@@ -290,7 +290,7 @@ returns the maximum integer value (in BigDecimal) which is less than or equal to  c = BigDecimal("-1.23456").floor #  ==> -2
-As shown in the following example,an optional integer argument (n) specifying the position +As shown in the following example,an optional integer argument (n) specifying the position of the target digit can be given.
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).
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).@@ -308,7 +308,7 @@ returns the minimum integer value (in BigDecimal) which is greater than or equal c = BigDecimal("-1.23456").ceil # ==> -1
-As shown in the following example,an optional integer argument (n) specifying the position +As shown in the following example,an optional integer argument (n) specifying the position of the target digit can be given.
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).
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).@@ -327,7 +327,7 @@ round a to the nearest 1(default)ÅD
The rounding operation changes according to BigDecimal::mode(BigDecimal::ROUND_MODE,flag) if specified. -As shown in the following example,an optional integer argument (n) specifying the position +As shown in the following example,an optional integer argument (n) specifying the position of the target digit can be given.
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).
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,7 +346,7 @@ c = BigDecimal::new("1.23356").round(3,BigDecimal::ROUND_HALF_EVEN) # ==> 1.2
• truncate[(n)]
• c = a.truncate
truncate a to the nearest 1ÅD
-As shown in the following example,an optional integer argument (n) specifying the position +As shown in the following example,an optional integer argument (n) specifying the position of the target digit can be given.
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).
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).@@ -373,7 +373,7 @@ converts to string(default results look like "0.xxxxxEn").
BigDecimal("1.23456").to_s  #  ==> "0.123456E1"
-If n(>0) is given,then a space is inserted to each of two parts divided by the decimal point +If n(>0) is given,then a space is inserted to each of two parts divided by the decimal point after every n digits for readability.
BigDecimal("0.1234567890123456789").to_s(10)   #  ==> "0.1234567890 123456789E0"@@ -390,7 +390,7 @@ BigDecimal("0.1234567890123456789").to_s("+10") #  ==> "+0.1234567890 123456789E BigDecimal("-0.1234567890123456789").to_s("10") #  ==> "-0.1234567890 123456789E0"
-At the end of the string,'E'(or 'e') or 'F'(or 'f') can be specified to change +At the end of the string,'E'(or 'e') or 'F'(or 'f') can be specified to change number representation.
BigDecimal("1234567890.123456789").to_s("E")  #  ==> "0.1234567890123456789E10"@@ -408,7 +408,7 @@ means a = 0.xxxxxxx*10**n.
• precs
• n,m = a.precs
-precs returns number of significant digits (n) and maximum number of +precs returns number of significant digits (n) and maximum number of significant digits (m) of a.
@@ -473,7 +473,7 @@ p a=BigDecimal::new("3.14",10)
should produce output like "#<0x112344:'0.314E1',4(12)%gt;". where "0x112344" is the address, '0.314E1' is the value,4 is the number of the significant digits,-and 12 is the maximum number of the significant digits +and 12 is the maximum number of the significant digits the object can hold.
@@ -527,12 +527,12 @@ same as ==,used in case statement.
2.A is the BigDecimal object but B is other than BigDecimal object
Operation is performed,after B is translated to corresponding BigDecimal object(because BigDecimal supports coerce method).
3.A is not the BigDecimal object but B is BigDecimal object
-
If A has coerce method,then B will translate A to corresponding +
If A has coerce method,then B will translate A to corresponding BigDecimal object and the operation is performed,otherwise an error occures.
String is not translated to BigDecimal in default.-Uncomment /* #define ENABLE_NUMERIC_STRING */ in bigdecimal.c, compile and install +Uncomment /* #define ENABLE_NUMERIC_STRING */ in bigdecimal.c, compile and install again if you want to enable string to BigDecimal conversion. Translation stops without error at the character representing non digit. For instance,"10XX" is translated to 10,"XXXX" is translated to 0.
@@ -563,7 +563,7 @@ and define coerce method within the new class.
Infinite numbers and NaN can be represented by string writing "+Infinity"(or "Infinity"),"-Infinity",and "NaN" respectively in your program. Infinite numbers can be obtained by 1.0/0.0(=Infinity) or -1.0/0.0(=-Infinity).

-NaN(Not a number) can be obtained by undefined computation like 0.0/0.0 +NaN(Not a number) can be obtained by undefined computation like 0.0/0.0 or Infinity-Infinity. Any computation including NaN results to NaN. Comparisons with NaN never become true,including comparison with NaN itself.@@ -602,7 +602,7 @@ where 'x' is any digit representing mantissa(kept in the array frac[]), BASE is base value(=10000 in 32 bit integer system), and n is the exponent value.
Larger BASE value enables smaller size of the array frac[],and increases computation speed.-The value of BASE is defined ind VpInit(). In 32 bit integer system, this value is +The value of BASE is defined ind VpInit(). In 32 bit integer system, this value is 10000. In 64 bit integer system, the value is 1000000000. When BASE is 10000,an element of the array frac[] can have value of from 0 to 9999. (up to 4 digits).
@@ -630,7 +630,7 @@ The decimal value 1234.56784321 is represented as(BASE=10000):
0.1234 5678 4321*(10000)**1 where frac[0]=1234,frac[1]=5678,frac[2]=4321,-Prec=3,sign=2,exponent=1. MaxPrec can be any value greater than or equal to +Prec=3,sign=2,exponent=1. MaxPrec can be any value greater than or equal to Prec.
@@ -657,7 +657,7 @@ The reason why I adopted decimal number representation for BigDecimal is:
end
-If the internal representation is binary,translation from decimal to +If the internal representation is binary,translation from decimal to binary is required and the translation error is inevitable. For example, 0.1 can not exactly be represented in binary.
0.1 => b1*2**(-1)+b1*2**(-2)+b3*2**(-3)+b4*2**(-4)....
@@ -669,7 +669,7 @@ Of course, exact "0.1" is printed if the rounding operation is properly done,
In binary representation,0.1 can not be represented in finite series of digit. But we only need one element(frac[0]=1) in decimal representation.-This means that we can always determine the size of the array frac[] in Real +This means that we can always determine the size of the array frac[] in Real structure. @@ -689,11 +689,11 @@ For the fundamental arithmetics such as addition,subtraction, multiplication,and division,I prepared 2 group of methods

1. +,-,*,/

-For the operation + - * /,you can not specify the resulting +For the operation + - * /,you can not specify the resulting number of significant digits.
Resulting number of significant digits are defined as:
-1.1 For *,resulting number of significant digits is the sum of the -significant digits of both side of the operator. For / ,resulting number of significant digits is the sum of the +1.1 For *,resulting number of significant digits is the sum of the+significant digits of both side of the operator. For / ,resulting number of significant digits is the sum of the maximum significant digits of both side of the operator.
1.2 For + and -,resulting number of significant digits is determined so that no round operation is needed.
@@ -705,7 +705,7 @@ which means more memory is required to keep computation results. But,the division such as c=1.0/3.0 will always be rounded.

-The length of the significant digits obtained from +,-,*,/ +The length of the significant digits obtained from +,-,*,/ is always defined by that of right and left side of the operator. To specify the length of the significant digits by your self, use methos add,sub,mult,div.@@ -724,7 +724,7 @@ decimal point.

4. Example

-Following example compute the ratio of the circumference of a circle to +Following example compute the ratio of the circumference of a circle to its diameter(pi=3.14159265358979....) using J.Machin's formula.

@@ -746,7 +746,7 @@ def big_pi(sig) # sig: Number of significant figures   k = BigDecimal::new("1")   w = BigDecimal::new("1")   t = BigDecimal::new("-80")-  while (u.nonzero? && u.exponent >= exp) +  while (u.nonzero? && u.exponent >= exp)     t   = t*m25     u   = t.div(k,sig)     pi  = pi + udiff --git a/ext/bigdecimal/bigdecimal_ja.html b/ext/bigdecimal/bigdecimal_ja.htmlindex 37bbcbb..cc44d61 100644--- a/ext/bigdecimal/bigdecimal_ja.html+++ b/ext/bigdecimal/bigdecimal_ja.html@@ -41,7 +41,7 @@ Ruby ɂĂ̏ڂe͈ȉURLQƂĂB  +

ڎ

@@ -73,8 +73,8 @@ Ruby ɂ Bignum ƂNXAS̐łvZ邱Ƃł܂B BigDecimal ܂ Ruby ̍ŐVłRubyy[W_E[hł܂B _E[hŐVł𓀂Aʏ̃CXg[菇sĉB Ruby CXg[΁A BigDecimal pł悤ɂȂ͂łB-\[Xt@C -bigdecimal.c,bigdecimal.h +\[Xt@C+bigdecimal.c,bigdecimal.h ̂Q݂̂łB

@@ -332,7 +332,7 @@ n>=0 ȂA_ȉ n+1 ʂ̐𑀍삵܂(_ȉAő n ɂ܂)
• round[(n[,b])]
• c = a.round
-NX\bh BigDecimal::mode(BigDecimal::ROUND_MODE,flag) Ŏw肵 +NX\bh BigDecimal::mode(BigDecimal::ROUND_MODE,flag) Ŏw肵 ROUND_MODE ɏ]Ċۂߑs܂B BigDecimal::mode(BigDecimal::ROUND_MODE,flag) ŉw肹AA w肵Ȃꍇ́u_ȉʂ̐ľܓĐiBigDecimal ljvɂ܂B
@@ -505,7 +505,7 @@ c = a.sqrt(n)
• <=>
• a==b Ȃ 0Aa > b Ȃ 1Aa < b Ȃ -1 ɂȂ܂B
-c = a <=> b +c = a <=> b
́AǂŎ̔@łB
@@ -753,7 +753,7 @@ def big_pi(sig) # sig: Number of significant figures k = BigDecimal::new("1") w = BigDecimal::new("1") t = BigDecimal::new("-80")- while (u.nonzero? && u.exponent >= exp) + while (u.nonzero? && u.exponent >= exp) t = t*m25 u = t.div(k,sig) pi = pi + udiff --git a/ext/bigdecimal/lib/bigdecimal/jacobian.rb b/ext/bigdecimal/lib/bigdecimal/jacobian.rbindex 3f47e43..8ab8362 100644--- a/ext/bigdecimal/lib/bigdecimal/jacobian.rb+++ b/ext/bigdecimal/lib/bigdecimal/jacobian.rb@@ -37,7 +37,7 @@ module Jacobian end end end- + # Computes the derivative of f[i] at x[i]. # fx is the value of f at x.diff --git a/ext/bigdecimal/lib/bigdecimal/util.rb b/ext/bigdecimal/lib/bigdecimal/util.rbindex 6d22d27..6e1697b 100644--- a/ext/bigdecimal/lib/bigdecimal/util.rb+++ b/ext/bigdecimal/lib/bigdecimal/util.rb@@ -8,7 +8,7 @@ class Float < Numeric # require 'bigdecimal/util' # # 0.5.to_d- # # => # + # # => # # def to_d BigDecimal(self.to_s)@@ -25,7 +25,7 @@ class String # require 'bigdecimal/util' # # "0.5".to_d- # # => # + # # => # # def to_d BigDecimal(self)@@ -69,7 +69,7 @@ class Rational < Numeric # r.to_d # # => # # r.to_d(3)- # # => # + # # => # def to_d(nFig=0) num = self.numerator.to_s if nFig<=0