Linux heracles.o2switch.net 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
/
opt
/
alt
/
ruby21
/
share
/
ri
/
2.1.0
/
system
/
BigDecimal
/
//opt/alt/ruby21/share/ri/2.1.0/system/BigDecimal/cdesc-BigDecimal.ri
U:RDoc::NormalClass[iI"BigDecimal:ET@I"Numeric;To:RDoc::Markup::Document:@parts[o;;[Ko:RDoc::Markup::Paragraph;[I"OBigDecimal provides arbitrary-precision floating point decimal arithmetic.;To:RDoc::Markup::BlankLine S: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";<code>'Infinity'</code>, <code>'+Infinity'</code> and ;TI".<code>'-Infinity'</code> (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"License;T@o; ;[I"FCopyright (C) 2002 by Shigeo Kobayashi <shigeo@tinyforest.gr.jp>.;T@o; ;[I"IYou may distribute under the terms of either the GNU General Public ;TI"FLicense or the Artistic License, as specified in the README file ;TI"$of the BigDecimal distribution.;T@o; ;[I"=Maintained by mrkn <mrkn@mrkn.jp> and ruby-core members.;T@o; ;[I"QDocumented by zzak <zachary@zacharyscott.net>, mathew <meta@pobox.com>, and ;TI"many other contributors.;T: @fileI" ext/bigdecimal/bigdecimal.c;T:0@omit_headings_from_table_of_contents_below0o;;[o; ;[I"OBigDecimal extends the native Numeric class to provide the #to_digits and ;TI"#to_d methods.;T@o; ;[I"JWhen you require BigDecimal in your application, this method will be ;TI"%available on BigDecimal objects.;T;I"*ext/bigdecimal/lib/bigdecimal/util.rb;T;0o;;[ ;I"(ext/json/lib/json/add/bigdecimal.rb;T;0;0;0[ [U:RDoc::Constant[i I" 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;[i I"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;[i I"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;[i I"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;[i I"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;[i I"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;[i I"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;[i I"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;[i I" 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;[i I"ROUND_DOWN;TI"BigDecimal::ROUND_DOWN;T00o;;[o; ;[I"?Indicates that values should be rounded towards zero. See ;TI"BigDecimal.mode.;T;@�;0@�@@�0U;[i I"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;[i I"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;[i I"ROUND_CEILING;TI"BigDecimal::ROUND_CEILING;T00o;;[o; ;[I"2Round towards +Infinity. See BigDecimal.mode.;T@;@�;0@�@@�0U;[i I"ROUND_FLOOR;TI"BigDecimal::ROUND_FLOOR;T00o;;[o; ;[I"2Round towards -Infinity. See BigDecimal.mode.;T@;@�;0@�@@�0U;[i I"ROUND_HALF_EVEN;TI" BigDecimal::ROUND_HALF_EVEN;T00o;;[o; ;[I":Round towards the even neighbor. See BigDecimal.mode.;T@;@�;0@�@@�0U;[i I" SIGN_NaN;TI"BigDecimal::SIGN_NaN;T00o;;[o; ;[I"AIndicates that a value is not a number. See BigDecimal.sign.;T@;@�;0@�@@�0U;[i I"SIGN_POSITIVE_ZERO;TI"#BigDecimal::SIGN_POSITIVE_ZERO;T00o;;[o; ;[I"7Indicates that a value is +0. See BigDecimal.sign.;T@;@�;0@�@@�0U;[i I"SIGN_NEGATIVE_ZERO;TI"#BigDecimal::SIGN_NEGATIVE_ZERO;T00o;;[o; ;[I"7Indicates that a value is -0. See BigDecimal.sign.;T@;@�;0@�@@�0U;[i I"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;[i I"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;[i I"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;[i I"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;[i I" INFINITY;TI"BigDecimal::INFINITY;T00o;;[o; ;[I"Positive infinity value.;T@;@�;0@�@@�0U;[i I"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[i 0o;;[ ;0;0[@�@�@�@�cRDoc::TopLevel