ruby-changes:21299
From: mrkn <ko1@a...>
Date: Wed, 28 Sep 2011 04:07:07 +0900 (JST)
Subject: [ruby-changes:21299] mrkn:r33348 (trunk): * ext/bigdecimal/bigdecimal_en.html: removed because this file isn't
mrkn 2011-09-28 04:06:52 +0900 (Wed, 28 Sep 2011) New Revision: 33348 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33348 Log: * ext/bigdecimal/bigdecimal_en.html: removed because this file isn't maintained now. * ext/bigdecimal/bigdecimal_ja.html: ditto. Removed files: trunk/ext/bigdecimal/bigdecimal_en.html trunk/ext/bigdecimal/bigdecimal_ja.html Modified files: trunk/ChangeLog Index: ChangeLog =================================================================== --- ChangeLog (revision 33347) +++ ChangeLog (revision 33348) @@ -1,3 +1,10 @@ +Tue Sep 28 04:05:00 2011 Kenta Murata <mrkn@m...> + + * ext/bigdecimal/bigdecimal_en.html: removed because this file isn't + maintained now. + + * ext/bigdecimal/bigdecimal_ja.html: ditto. + Tue Sep 27 09:55:40 2011 KOSAKI Motohiro <kosaki.motohiro@g...> * thread_pthread.c: make native_fd_select(). Index: ext/bigdecimal/bigdecimal_en.html =================================================================== --- ext/bigdecimal/bigdecimal_en.html (revision 33347) +++ ext/bigdecimal/bigdecimal_en.html (revision 33348) @@ -1,792 +0,0 @@ -<HTML> -<HEAD> -<META HTTP-EQUIV="Content-Type" CONTENT="text/html"> -<style type="text/css"><!-- -body { color: #3f0f0f; background: #fefeff; margin-left: 2em; margin-right: 2em;} -h1 { color: #ffffff; background-color: #3939AD; border-color: #FF00FF; width: 100%; border-style: solid; - border-top-width: 0.1em; border-bottom-width: 0.1em; border-right: none; border-left: none; - padding: 0.1em; font-weight: bold; font-size: 160%; text-align: center;} -h2 { color: #00007f; background-color: #e7e7ff; border-color: #000094; width: 100%; border-style: solid; border-le ft: none; border-right: none; border-top-width: 0.1em; border-bottom-width: 0.1em; padding: 0.1em; - font-weight: bold; font-size: 110%; -} -h3 { color: #00007f; padding: 0.2em; font-size: 110%;} -h4, h5 { color: #000000; padding: 0.2em; font-size: 100%;} -table { margin-top: 0.2em; margin-bottom: 0.2em; margin-left: 2em; margin-right: 2em;} -caption { color: #7f0000; font-weight: bold;} -th { background: #e7e7ff; padding-left: 0.2em; padding-right: 0.2em;} -td { background: #f3f7ff; padding-left: 0.2em; padding-right: 0.2em;} -code { color: #0000df;} -dt { margin-top: 0.2em;} -li { margin-top: 0.2em;} -pre -{ BACKGROUND-COLOR: #d0d0d0; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; - BORDER-RIGHT: medium none; BORDER-TOP: medium none; LINE-HEIGHT: 100%; MARGIN: 12px 12px 12px 12px; - PADDING-BOTTOM: 12px; PADDING-LEFT: 12px; PADDING-RIGHT: 12px; PADDING-TOP: 12px; - WHITE-SPACE: pre; WIDTH: 100% -} ---></style> - -<TITLE>BigDecimal:An extension library for Ruby</TITLE> -</HEAD> -<BODY BGCOLOR=#FFFFE0> -<H1>BigDecimal(Variable Precision Floating Library for Ruby)</H1> -<DIV align="right"><A HREF="./bigdecimal_ja.html">Japanese</A></DIV><BR> -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:<BR> -<UL> -<LI><A HREF="http://www.ruby-lang.org/en/">http://www.ruby-lang.org/en/</A>:Official Ruby page(English).</LI> -<LI><A HREF="http://kahori.com/ruby/ring/">http://kahori.com/ruby/ring/</A>:Mutually linked pages relating to Ruby(Japanese). -</LI> -</UL> -NOTE:<BR> - This software is provided "AS IS" and without any express or - implied warranties,including,without limitation,the implied - warranties of merchantability and fitness for a particular - purpose. For the details,see COPYING and README included in this - distribution. -<BR> -<hr> - -<H2>Contents</H2> -<UL> -<LI><A HREF="#INTRO">Introduction</LI> -<LI><A HREF="#SPEC">Usage and methods</A></LI> -<LI><A HREF="#UNDEF">Infinity,NaN,Zero</A></LI> -<LI><A HREF="#STRUCT">Internal structure</A></LI> -<LI><A HREF="#BASE">Binary or decimal number representation</A></LI> -<LI><A HREF="#PREC">Resulting number of significant digits</A></LI> -</UL> -<HR> - -<A NAME="#INTRO"> -<H2>Introduction</H2> -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. -This is why I made variable length floating class BigDecimal. -Feel free to send any comments or bug reports to me. -<A HREF="mailto:shigeo@t...">shigeo@t...</A> -I will try(but can't promise) to fix bugs reported. -<hr> -<H2>Installation</H2> -The Ruby latest version can be downloaded from <A HREF="http://www.ruby-lang.org/en/">Official Ruby page</A>. -Once decompress the downloaded Ruby archive,follow the normal installation procedures according to the -documents included. - -<A NAME="#SPEC"> -<H2>Usage and methods</H2> -Suppose you already know Ruby programming, -to create BigDecimal objects,the program would like:<BR> - -<CODE><PRE> - require 'bigdecimal' - a=BigDecimal::new("0.123456789123456789") - b=BigDecimal("123456.78912345678",40) - c=a+b -</PRE></CODE> - -<H3>List of methods</H3> -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. -<P> -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: -<CODE><PRE> -require "bigdecimal/math.rb" -</PRE></CODE> -For details,see the math.rb code and comments. -Other utility methods are in util.rb. -To use util.rb, require it as: -<CODE><PRE> -require "bigdecimal/util.rb" -</PRE></CODE> -For details,see the util.rb code. - -<H4><U>Class methods</U></H4> -<UL> -<LI><B>new</B></LI><BLOCKQUOTE> -"new" method creates a new BigDecimal object.<BR> -a=BigDecimal::new(s[,n]) or<BR> -a=BigDecimal(s[,n]) or<BR> -where:<BR> -s: Initial value string. Spaces will be ignored. Any unrecognizable character for -representing initial value terminates the string.<BR> -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. -Actual number of digits handled in computations are usually greater than n.<BR> -n is useful when performing divisions like -<CODE><PRE> -BigDecimal("1") / BigDecimal("3") # => 0.3333333333 33E0 -BigDecimal("1",10) / BigDecimal("3",10) # => 0.3333333333 3333333333 33333333E0 -</PRE></CODE> -but the resulting digits obtained may differ in future version. -</BLOCKQUOTE> - -<LI><B>mode</B></LI><BLOCKQUOTE> -f = BigDecimal.mode(s[,v])<BR> -mode method controls BigDecimal computation. If the second argument is not given or is nil,then the value -of current setting is returned. -Following usage are defined.<BR> -<P><B>[EXCEPTION control]</B><P> -Actions when computation results NaN or Infinity can be defined as follows. -<P> -<BLOCKQUOTE> -f = BigDecimal::mode(BigDecimal::EXCEPTION_NaN,flag)<BR> -f = BigDecimal::mode(BigDecimal::EXCEPTION_INFINITY,flag)<BR> -f = BigDecimal::mode(BigDecimal::EXCEPTION_UNDERFLOW,flag)<BR> -f = BigDecimal::mode(BigDecimal::EXCEPTION_OVERFLOW,flag)<BR> -f = BigDecimal::mode(BigDecimal::EXCEPTION_ZERODIVIDE,flag)<BR> -f = BigDecimal::mode(BigDecimal::EXCEPTION_ALL,flag)<BR> -</BLOCKQUOTE> -EXCEPTION_NaN controls the execution when computation results to NaN.<BR> -EXCEPTION_INFINITY controls the execution when computation results to Infinity.<BR> -EXCEPTION_UNDERFLOW controls the execution when computation underflows.<BR> -EXCEPTION_OVERFLOW controls the execution when computation overflows.<BR> -EXCEPTION_ZERODIVIDE controls the execution when zero-division occurs.<BR> -EXCEPTION_ALL controls the execution when any defined exception occurs.<BR> -If the flag is true,then the relating exception is thrown.<BR> -No exception is thrown when the flag is false(default) and computation -continues with the result:<BR> -<BLOCKQUOTE> -EXCEPTION_NaN results to NaN<BR> -EXCEPTION_INFINITY results to +Infinity or -Infinity<BR> -EXCEPTION_UNDERFLOW results to 0.<BR> -EXCEPTION_OVERFLOW results to +Infinity or -Infinity<BR> -EXCEPTION_ZERODIVIDE results to +Infinity or -Infinity<BR> -</BLOCKQUOTE> -EXCEPTION_INFINITY,EXCEPTION_OVERFLOW, and EXCEPTION_ZERODIVIDE are - currently the same.<BR> -The return value of mode method is the value set.<BR> -If nil is specified for the second argument,then current setting is returned.<BR> -Suppose the return value of the mode method is f,then - f & BigDecimal::EXCEPTION_NaN !=0 means EXCEPTION_NaN is set to on. -<P> -<B>[ROUND error control]</B><P> -Rounding operation can be controlled as: -<BLOCKQUOTE> -f = BigDecimal::mode(BigDecimal::ROUND_MODE,flag) -</BLOCKQUOTE> -where flag must be one of: -<TABLE> - -<TR><TD>ROUND_UP</TD><TD>round away from zero.</TD></TR> -<TR><TD>ROUND_DOWN</TD><TD>round towards zero(truncate).</TD></TR> -<TR><TD>ROUND_HALF_UP</TD><TD>round up if the digit >= 5 otherwise truncated(default).</TD></TR> -<TR><TD>ROUND_HALF_DOWN</TD><TD>round up if the digit >= 6 otherwise truncated.</TD></TR> -<TR><TD>ROUND_HALF_EVEN</TD><TD>round towards the even neighbor(Banker's rounding). -<TR><TD>ROUND_CEILING</TD><TD>round towards positive infinity(ceil).</TD></TR> -<TR><TD>ROUND_FLOOR</TD><TD>round towards negative infinity(floor).</TD></TR> -</TABLE> -New rounding mode is returned. If nil is specified for the second argument,then current setting is returned.<BR> -The digit location for rounding operation can not be specified by this mode method, -use truncate/round/ceil/floor/add/sub/mult/div methods for each instance instead. -</BLOCKQUOTE> - -<LI><B>limit[(n)]</B></LI><BLOCKQUOTE> -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 -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.<BR> -The limit has no more priority than instance methods such as truncate,round,ceil,floor,add,sub,mult,and div. <BR> -mf = BigDecimal::limit(n)<BR> -</BLOCKQUOTE> - -<LI><B>double_fig</B></LI><BLOCKQUOTE> -double_fig is a class method which returns the number of digits -the Float class can have. -<CODE><PRE> - p BigDecimal::double_fig # ==> 20 (depends on the CPU etc.) -</PRE></CODE> -The equivalent C programs which calculates the value of -double_fig is: -<CODE><PRE> - double v = 1.0; - int double_fig = 0; - while(v + 1.0 > 1.0) { - ++double_fig; - v /= 10; - } -</PRE></CODE> -</BLOCKQUOTE> - -<LI><B>BASE</B></LI><BLOCKQUOTE> -Base value used in the BigDecimal calculation. -On 32 bits integer system,the value of BASE is 10000.<BR> -b = BigDecimal::BASE<BR> -</BLOCKQUOTE> -</UL> - -<H4><U>Instance methods</U></H4> -<UL> -<LI><B>+</B></LI><BLOCKQUOTE> -addition(c = a + b)<BR> -For the resulting number of significant digits of c,see <A HREF="#PREC">Resulting number of significant digits</A>. - -</BLOCKQUOTE> -<LI><B>-</B></LI><BLOCKQUOTE> -subtraction (c = a - b) or negation (c = -a)<BR> -For the resulting number of significant digits of c,see <A HREF="#PREC">Resulting number of significant digits</A>. - -</BLOCKQUOTE> -<LI><B>*</B></LI><BLOCKQUOTE> -multiplication(c = a * b)<BR> -For the resulting number of significant digits of c,see <A HREF="#PREC">Resulting number of significant digits</A>. - -</BLOCKQUOTE> -<LI><B>/</B></LI><BLOCKQUOTE> -division(c = a / b)<BR> -For the resulting number of significant digits of c,see <A HREF="#PREC">Resulting number of significant digits</A>. -</BLOCKQUOTE> - -<LI><B>add(b,n)</B></LI><BLOCKQUOTE> -c = a.add(b,n)<BR> -c = a.add(b,n) performs c = a + b.<BR> -If n is less than the actual significant digits of a + b, -then c is rounded properly according to the BigDecimal.limit.<BR> -If n is zero,then the result is the same as +'s. -</BLOCKQUOTE> -<LI><B>sub(b,n)</B></LI><BLOCKQUOTE> -c = a.sub(b,n)<BR> -c = a.sub(b,n) performs c = a - b.<BR> -If n is less than the actual significant digits of a - b, -then c is rounded properly according to the BigDecimal.limit.<BR> -If n is zero,then the result is the same as -'s. - -</BLOCKQUOTE> -<LI><B>mult(b,n)</B></LI><BLOCKQUOTE> -c = a.mult(b,n)<BR> -c = a.mult(b,n) performs c = a * b.<BR> -If n is less than the actual significant digits of a * b, -then c is rounded properly according to the BigDecimal.limit.<BR> -If n is zero,then the result is the same as *'s. - -</BLOCKQUOTE> -<LI><B>div(b[,n])</B></LI><BLOCKQUOTE> -c = a.div(b,n)<BR> -c = a.div(b,n) performs c = a / b.<BR> -If n is less than the actual significant digits of a / b, -then c is rounded properly according to the BigDecimal.limit.<BR> -If n is zero,then the result is the same as /'s. -If n is not given,then the result will be an integer(BigDecimal) like Float#div. -</BLOCKQUOTE> - -<LI><B>fix</B></LI><BLOCKQUOTE> -c = a.fix<BR> -returns integer part of a.<BR> - -</BLOCKQUOTE> -<LI><B>frac</B></LI><BLOCKQUOTE> -c = a.frac<BR> -returns fraction part of a.<BR> - -</BLOCKQUOTE> -<LI><B>floor[(n)]</B></LI><BLOCKQUOTE> -c = a.floor<BR> -returns the maximum integer value (in BigDecimal) which is less than or equal to a. -<CODE><PRE> - c = BigDecimal("1.23456").floor # ==> 1 - c = BigDecimal("-1.23456").floor # ==> -2 -</PRE></CODE> - -As shown in the following example,an optional integer argument (n) specifying the position -of the target digit can be given.<BR> -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> -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). -<CODE><PRE> - c = BigDecimal("1.23456").floor(4) # ==> 1.2345 - c = BigDecimal("15.23456").floor(-1) # ==> 10.0 -</PRE></CODE> - -</BLOCKQUOTE> -<LI><B>ceil[(n)]</B></LI><BLOCKQUOTE> -c = a.ceil<BR> -returns the minimum integer value (in BigDecimal) which is greater than or equal to a. -<CODE><PRE> - c = BigDecimal("1.23456").ceil # ==> 2 - c = BigDecimal("-1.23456").ceil # ==> -1 -</PRE></CODE> - -As shown in the following example,an optional integer argument (n) specifying the position -of the target digit can be given.<BR> -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> -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). -<CODE><PRE> - c = BigDecimal("1.23456").ceil(4) # ==> 1.2346 - c = BigDecimal("15.23456").ceil(-1) # ==> 20.0 -</PRE></CODE> - -</BLOCKQUOTE> -<LI><B>round[(n[,b])]</B></LI><BLOCKQUOTE> -c = a.round<BR> -round a to the nearest 1(default)D<BR> -<CODE><PRE> - c = BigDecimal("1.23456").round # ==> 1 - c = BigDecimal("-1.23456").round # ==> -1 -</PRE></CODE> -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 -of the target digit can be given.<BR> -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> -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). -<CODE><PRE> -c = BigDecimal::new("1.23456").round(4) # ==> 1.2346 -c = BigDecimal::new("15.23456").round(-1) # ==> 20.0 -</PRE></CODE> - -Rounding operation can be specified by setting the second optional argument b with the valid ROUND_MODE.<BR> -<CODE><PRE> -c = BigDecimal::new("1.23456").round(3,BigDecimal::ROUND_HALF_EVEN) # ==> 1.234 -c = BigDecimal::new("1.23356").round(3,BigDecimal::ROUND_HALF_EVEN) # ==> 1.234 -</PRE></CODE> - -</BLOCKQUOTE> -<LI><B>truncate[(n)]</B></LI><BLOCKQUOTE> -c = a.truncate<BR> -truncate a to the nearest 1D<BR> -As shown in the following example,an optional integer argument (n) specifying the position -of the target digit can be given.<BR> -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> -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). - -<CODE><PRE> -c = BigDecimal::new("1.23456").truncate(4) # ==> 1.2345 -c = BigDecimal::new("15.23456").truncate(-1) # ==> 10.0 -</PRE></CODE> -</BLOCKQUOTE> -<LI><B>abs</B></LI><BLOCKQUOTE> -c = a.abs<BR> -returns an absolute value of a.<BR> - -</BLOCKQUOTE> -<LI><B>to_i</B></LI><BLOCKQUOTE> -changes a to an integer.<BR> -i = a.to_i<BR> -i becomes to Fixnum or Bignum. -If a is Infinity or NaN,then i becomes to nil. - -</BLOCKQUOTE> -<LI><B>to_s[(n)]</B></LI><BLOCKQUOTE> -converts to string(default results look like "0.xxxxxEn"). -<CODE><PRE> -BigDecimal("1.23456").to_s # ==> "0.123456E1" -</PRE></CODE> -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. -<CODE><PRE> -BigDecimal("0.1234567890123456789").to_s(10) # ==> "0.1234567890 123456789E0" -</PRE></CODE> -n can be a string representing a positive integer number. -<CODE><PRE> -BigDecimal("0.1234567890123456789").to_s("10") # ==> "0.1234567890 123456789E0" -</PRE></CODE> -If the first character is '+'(or ' '),then '+'(or ' ') will be set before value string -when the value is positive. -<CODE><PRE> -BigDecimal("0.1234567890123456789").to_s(" 10") # ==> " 0.1234567890 123456789E0" -BigDecimal("0.1234567890123456789").to_s("+10") # ==> "+0.1234567890 123456789E0" -BigDecimal("-0.1234567890123456789").to_s("10") # ==> "-0.1234567890 123456789E0" -</PRE></CODE> - -At the end of the string,'E'(or 'e') or 'F'(or 'f') can be specified to change -number representation. -<CODE><PRE> -BigDecimal("1234567890.123456789").to_s("E") # ==> "0.1234567890123456789E10" -BigDecimal("1234567890.123456789").to_s("F") # ==> "1234567890.123456789" -BigDecimal("1234567890.123456789").to_s("5E") # ==> "0.12345 67890 12345 6789E10" -BigDecimal("1234567890.123456789").to_s("5F") # ==> "12345 67890.12345 6789" -</PRE></CODE> - -</BLOCKQUOTE> -<LI><B>exponent</B></LI><BLOCKQUOTE> -returns an integer holding exponent value of a.<BR> -n = a.exponent <BR> -means a = 0.xxxxxxx*10**n. -</BLOCKQUOTE> - -<LI><B>precs</B></LI><BLOCKQUOTE> -n,m = a.precs <BR> -precs returns number of significant digits (n) and maximum number of -significant digits (m) of a. -</BLOCKQUOTE> - -<LI><B>to_f</B></LI><BLOCKQUOTE> -Creates a new Float object having (nearly) the same value. -Use split method if you want to convert by yourself. -</BLOCKQUOTE> - -</BLOCKQUOTE> -<LI><B>sign</B></LI><BLOCKQUOTE> -n = a.sign <BR> -returns positive value if a > 0,negative value if a < 0, -otherwise zero if a == 0.<BR> -where the value of n means that a is:<BR> -n = BigDecimal::SIGN_NaN(0) : a is NaN<BR> -n = BigDecimal::SIGN_POSITIVE_ZERO(1) : a is +0<BR> -n = BigDecimal::SIGN_NEGATIVE_ZERO(-1) : a is -0<BR> -n = BigDecimal::SIGN_POSITIVE_FINITE(2) : a is positive<BR> -n = BigDecimal::SIGN_NEGATIVE_FINITE(-2) : a is negative<BR> -n = BigDecimal::SIGN_POSITIVE_INFINITE(3) : a is +Infinity<BR> -n = BigDecimal::SIGN_NEGATIVE_INFINITE(-3) : a is -Infinity<BR> -The value in () is the actual value,see (<A HREF="#STRUCT">Internal structure</A>.<BR> - -</BLOCKQUOTE> -<LI><B>nan?</B></LI><BLOCKQUOTE> -a.nan? returns True when a is NaN. - -</BLOCKQUOTE> -<LI><B>infinite?</B></LI><BLOCKQUOTE> -a.infinite? returns 1 when a is Infinity, -1 when a is -Infinity, nil otherwise. - -</BLOCKQUOTE> -<LI><B>finite?</B></LI><BLOCKQUOTE> -a.finite? returns true when a is neither Infinity nor NaN. -</BLOCKQUOTE> - -<LI><B>zero?</B></LI><BLOCKQUOTE> -c = a.zero?<BR> -returns true if a is equal to 0,otherwise returns false<BR> -</BLOCKQUOTE> -<LI><B>nonzero?</B></LI><BLOCKQUOTE> -c = a.nonzero?<BR> -returns nil if a is 0,otherwise returns a itself.<BR> -</BLOCKQUOTE> - -<LI><B>split</B></LI><BLOCKQ (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/