U:RDoc::NormalClass[iI"BigDecimal:ET@I" Numeric;To:RDoc::Markup::Document: @parts[o;;[Po:RDoc::Markup::Paragraph;[I"OBigDecimal provides arbitrary-precision floating point decimal arithmetic.;To:RDoc::Markup::BlankLineS:RDoc::Markup::Heading: leveli: textI"Introduction;T@o; ;[I"ORuby provides built-in support for arbitrary precision integer arithmetic.;T@o; ;[I"For example:;T@o:RDoc::Markup::Verbatim;[I"*42**13 #=> 1265437718438866624512 ;T: @format0o; ;[I"RBigDecimal provides similar support for very large or very accurate floating ;TI"point numbers.;T@o; ;[ I"KDecimal arithmetic is also useful for general calculation, because it ;TI"Pprovides the correct answers people expect--whereas normal binary floating ;TI"Opoint arithmetic often introduces subtle errors because of the conversion ;TI" between base 10 and base 2.;T@o; ;[I"For example, try:;T@o;;[ I" sum = 0 ;TI"10_000.times do ;TI" sum = sum + 0.0001 ;TI" end ;TI"&print sum #=> 0.9999999999999062 ;T;0o; ;[I"'and contrast with the output from:;T@o;;[ I"require 'bigdecimal' ;TI" ;TI"sum = BigDecimal.new("0") ;TI"10_000.times do ;TI", sum = sum + BigDecimal.new("0.0001") ;TI" end ;TI"print sum #=> 0.1E1 ;T;0o; ;[I"Similarly:;T@o;;[I"O(BigDecimal.new("1.2") - BigDecimal("1.0")) == BigDecimal("0.2") #=> true ;TI" ;TI""(1.2 - 1.0) == 0.2 #=> false ;T;0S; ; i; I"4Special features of accurate decimal arithmetic;T@o; ;[I"KBecause BigDecimal is more accurate than normal binary floating point ;TI"1arithmetic, it requires some special values.;T@S; ; i; I" Infinity;T@o; ;[I"NBigDecimal sometimes needs to return infinity, for example if you divide ;TI"a value by zero.;T@o;;[I"ABigDecimal.new("1.0") / BigDecimal.new("0.0") #=> Infinity ;TI"CBigDecimal.new("-1.0") / BigDecimal.new("0.0") #=> -Infinity ;T;0o; ;[I"HYou can represent infinite numbers to BigDecimal using the strings ;TI";'Infinity', '+Infinity' and ;TI".'-Infinity' (case-sensitive);T@S; ; i; I"Not a Number;T@o; ;[I"OWhen a computation results in an undefined value, the special value +NaN+ ;TI"&(for 'not a number') is returned.;T@o; ;[I" Example:;T@o;;[I";BigDecimal.new("0.0") / BigDecimal.new("0.0") #=> NaN ;T;0o; ;[I"*You can also create undefined values.;T@o; ;[I"PNaN is never considered to be the same as any other value, even NaN itself:;T@o;;[I"n = BigDecimal.new('NaN') ;TI"n == 0.0 #=> false ;TI"n == n #=> false ;T;0S; ; i; I"Positive and negative zero;T@o; ;[I"QIf a computation results in a value which is too small to be represented as ;TI"Pa BigDecimal within the currently specified limits of precision, zero must ;TI"be returned.;T@o; ;[I"QIf the value which is too small to be represented is negative, a BigDecimal ;TI"(value of negative zero is returned.;T@o;;[I"BBigDecimal.new("1.0") / BigDecimal.new("-Infinity") #=> -0.0 ;T;0o; ;[I"DIf the value is positive, a value of positive zero is returned.;T@o;;[I"@BigDecimal.new("1.0") / BigDecimal.new("Infinity") #=> 0.0 ;T;0o; ;[I"B(See BigDecimal.mode for how to specify limits of precision.);T@o; ;[I"RNote that +-0.0+ and +0.0+ are considered to be the same for the purposes of ;TI"comparison.;T@o; ;[I"ONote also that in mathematics, there is no particular concept of negative ;TI":or positive zero; true mathematical zero has no sign.;T@S; ; i; I"bigdecimal/util;T@o; ;[I"BWhen you require +bigdecimal/util+, the #to_d method will be ;TI"Favailable on BigDecimal and the native Integer, Float, Rational, ;TI"and String classes:;T@o;;[ I"require 'bigdecimal/util' ;TI" ;TI"!42.to_d # => 0.42e2 ;TI" 0.5.to_d # => 0.5e0 ;TI""(2/3r).to_d(3) # => 0.667e0 ;TI" "0.5".to_d # => 0.5e0 ;T;0S; ; i; I" License;T@o; ;[I"FCopyright (C) 2002 by Shigeo Kobayashi .;T@o; ;[I"FBigDecimal is released under the Ruby and 2-clause BSD licenses. ;TI"!See LICENSE.txt for details.;T@o; ;[I"=Maintained by mrkn and ruby-core members.;T@o; ;[I"QDocumented by zzak , mathew , and ;TI"many other contributors.;T: @fileI" ext/bigdecimal/bigdecimal.c;T:0@omit_headings_from_table_of_contents_below0o;;[;I"*ext/bigdecimal/lib/bigdecimal/util.rb;T;0o;;[;I"(ext/json/lib/json/add/bigdecimal.rb;T;0;0;0[[U:RDoc::Constant[iI" BASE;TI"BigDecimal::BASE;T00o;;[o; ;[ I"IBase value used in internal calculations. On a 32 bit system, BASE ;TI"Jis 10000, indicating that calculation is done in groups of 4 digits. ;TI"J(If it were larger, BASE**2 wouldn't fit in 32 bits, so you couldn't ;TI"Kguarantee that two groups could always be multiplied together without ;TI"overflow.);T;@©;0@©@cRDoc::NormalClass0U;[iI"EXCEPTION_ALL;TI"BigDecimal::EXCEPTION_ALL;T00o;;[o; ;[I"EDetermines whether overflow, underflow or zero divide result in ;TI"4an exception being thrown. See BigDecimal.mode.;T;@©;0@©@@¿0U;[iI"EXCEPTION_NaN;TI"BigDecimal::EXCEPTION_NaN;T00o;;[o; ;[I"GDetermines what happens when the result of a computation is not a ;TI"'number (NaN). See BigDecimal.mode.;T;@©;0@©@@¿0U;[iI"EXCEPTION_INFINITY;TI"#BigDecimal::EXCEPTION_INFINITY;T00o;;[o; ;[I"ADetermines what happens when the result of a computation is ;TI"$infinity. See BigDecimal.mode.;T;@©;0@©@@¿0U;[iI"EXCEPTION_UNDERFLOW;TI"$BigDecimal::EXCEPTION_UNDERFLOW;T00o;;[o; ;[I"DDetermines what happens when the result of a computation is an ;TI"Kunderflow (a result too small to be represented). See BigDecimal.mode.;T;@©;0@©@@¿0U;[iI"EXCEPTION_OVERFLOW;TI"#BigDecimal::EXCEPTION_OVERFLOW;T00o;;[o; ;[I"DDetermines what happens when the result of a computation is an ;TI"Joverflow (a result too large to be represented). See BigDecimal.mode.;T;@©;0@©@@¿0U;[iI"EXCEPTION_ZERODIVIDE;TI"%BigDecimal::EXCEPTION_ZERODIVIDE;T00o;;[o; ;[I"CDetermines what happens when a division by zero is performed. ;TI"See BigDecimal.mode.;T;@©;0@©@@¿0U;[iI"ROUND_MODE;TI"BigDecimal::ROUND_MODE;T00o;;[o; ;[I"GDetermines what happens when a result must be rounded in order to ;TI">fit in the appropriate number of significant digits. See ;TI"BigDecimal.mode.;T;@©;0@©@@¿0U;[iI" ROUND_UP;TI"BigDecimal::ROUND_UP;T00o;;[o; ;[I"AIndicates that values should be rounded away from zero. See ;TI"BigDecimal.mode.;T;@©;0@©@@¿0U;[iI"ROUND_DOWN;TI"BigDecimal::ROUND_DOWN;T00o;;[o; ;[I"?Indicates that values should be rounded towards zero. See ;TI"BigDecimal.mode.;T;@©;0@©@@¿0U;[iI"ROUND_HALF_UP;TI"BigDecimal::ROUND_HALF_UP;T00o;;[o; ;[I"KIndicates that digits >= 5 should be rounded up, others rounded down. ;TI"See BigDecimal.mode.;T@;@©;0@©@@¿0U;[iI"ROUND_HALF_DOWN;TI" BigDecimal::ROUND_HALF_DOWN;T00o;;[o; ;[I"KIndicates that digits >= 6 should be rounded up, others rounded down. ;TI"See BigDecimal.mode.;T;@©;0@©@@¿0U;[iI"ROUND_CEILING;TI"BigDecimal::ROUND_CEILING;T00o;;[o; ;[I"2Round towards +Infinity. See BigDecimal.mode.;T@;@©;0@©@@¿0U;[iI"ROUND_FLOOR;TI"BigDecimal::ROUND_FLOOR;T00o;;[o; ;[I"2Round towards -Infinity. See BigDecimal.mode.;T@;@©;0@©@@¿0U;[iI"ROUND_HALF_EVEN;TI" BigDecimal::ROUND_HALF_EVEN;T00o;;[o; ;[I":Round towards the even neighbor. See BigDecimal.mode.;T@;@©;0@©@@¿0U;[iI" SIGN_NaN;TI"BigDecimal::SIGN_NaN;T00o;;[o; ;[I"AIndicates that a value is not a number. See BigDecimal.sign.;T@;@©;0@©@@¿0U;[iI"SIGN_POSITIVE_ZERO;TI"#BigDecimal::SIGN_POSITIVE_ZERO;T00o;;[o; ;[I"7Indicates that a value is +0. See BigDecimal.sign.;T@;@©;0@©@@¿0U;[iI"SIGN_NEGATIVE_ZERO;TI"#BigDecimal::SIGN_NEGATIVE_ZERO;T00o;;[o; ;[I"7Indicates that a value is -0. See BigDecimal.sign.;T@;@©;0@©@@¿0U;[iI"SIGN_POSITIVE_FINITE;TI"%BigDecimal::SIGN_POSITIVE_FINITE;T00o;;[o; ;[I"HIndicates that a value is positive and finite. See BigDecimal.sign.;T@;@©;0@©@@¿0U;[iI"SIGN_NEGATIVE_FINITE;TI"%BigDecimal::SIGN_NEGATIVE_FINITE;T00o;;[o; ;[I"HIndicates that a value is negative and finite. See BigDecimal.sign.;T@;@©;0@©@@¿0U;[iI"SIGN_POSITIVE_INFINITE;TI"'BigDecimal::SIGN_POSITIVE_INFINITE;T00o;;[o; ;[I"JIndicates that a value is positive and infinite. See BigDecimal.sign.;T@;@©;0@©@@¿0U;[iI"SIGN_NEGATIVE_INFINITE;TI"'BigDecimal::SIGN_NEGATIVE_INFINITE;T00o;;[o; ;[I"JIndicates that a value is negative and infinite. See BigDecimal.sign.;T@;@©;0@©@@¿0U;[iI" INFINITY;TI"BigDecimal::INFINITY;T00o;;[o; ;[I"Positive infinity value.;T@;@©;0@©@@¿0U;[iI"NAN;TI"BigDecimal::NAN;T00o;;[o; ;[I"'Not a Number' value.;T@;@©;0@©@@¿0[[[I" class;T[[: public[[I" _load;TI" ext/bigdecimal/bigdecimal.c;T[I"double_fig;T@¤[I"json_create;FI"(ext/json/lib/json/add/bigdecimal.rb;T[I" limit;T@¤[I" mode;T@¤[I"new;T@¤[I"save_exception_mode;T@¤[I"save_limit;T@¤[I"save_rounding_mode;T@¤[I"ver;T@¤[:protected[[: private[[I" instance;T[[;[<[I"%;T@¤[I"*;T@¤[I"**;T@¤[I"+;T@¤[I"+@;T@¤[I"-;T@¤[I"-@;T@¤[I"/;T@¤[I"<;T@¤[I"<=;T@¤[I"<=>;T@¤[I"==;T@¤[I"===;T@¤[I">;T@¤[I">=;T@¤[I" _dump;T@¤[I"abs;T@¤[I"add;T@¤[I" as_json;F@©[I" ceil;T@¤[I" coerce;T@¤[I"div;T@¤[I" divmod;T@¤[I" eql?;T@¤[I" exponent;T@¤[I" finite?;T@¤[I"fix;T@¤[I" floor;T@¤[I" frac;T@¤[I" hash;T@¤[I"infinite?;T@¤[I" inspect;T@¤[I" modulo;T@¤[I" mult;T@¤[I" nan?;T@¤[I" nonzero?;T@¤[I" power;T@¤[I" precs;T@¤[I"quo;T@¤[I"remainder;T@¤[I" round;T@¤[I" sign;T@¤[I" split;T@¤[I" sqrt;T@¤[I"sub;T@¤[I" to_d;FI"*ext/bigdecimal/lib/bigdecimal/util.rb;T[I"to_digits;F@[I" to_f;T@¤[I" to_i;T@¤[I" to_int;T@¤[I" to_json;F@©[I" to_r;T@¤[I" to_s;T@¤[I" truncate;T@¤[I" zero?;T@¤[;[[;[[[U:RDoc::Context::Section[i0o;;[;0;0[@©@¬@¯@¯cRDoc::TopLevel