From ce6fd792adec3dd0a1891c814cd48e929b396b2c Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 9 May 2007 04:11:41 +0000 Subject: [PATCH] * numeric.c: purged trailing spaces. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- numeric.c | 234 +++++++++++++++++++++++++++--------------------------- 1 file changed, 117 insertions(+), 117 deletions(-) diff --git a/numeric.c b/numeric.c index a6df81639f..6734c836f1 100644 --- a/numeric.c +++ b/numeric.c @@ -83,14 +83,14 @@ rb_num_zerodiv() /* * call-seq: * num.coerce(numeric) => array - * + * * If aNumeric is the same type as num, returns an array * containing aNumeric and num. Otherwise, returns an * array with both aNumeric and num represented as * Float objects. This coercion mechanism is used by * Ruby to handle mixed-type numeric operations: it is intended to * find a compatible common type between the two operands of the operator. - * + * * 1.coerce(2.5) #=> [2.5, 1.0] * 1.2.coerce(3) #=> [3.0, 1.2] * 1.coerce(2) #=> [2, 1] @@ -161,7 +161,7 @@ VALUE rb_num_coerce_cmp(x, y) VALUE x, y; { - if (do_coerce(&x, &y, Qfalse)) + if (do_coerce(&x, &y, Qfalse)) return rb_funcall(x, ruby_frame->orig_func, 1, y); return Qnil; } @@ -194,7 +194,7 @@ num_sadded(x, name) rb_raise(rb_eTypeError, "can't define singleton method \"%s\" for %s", rb_id2name(rb_to_id(name)), - rb_obj_classname(x)); + rb_obj_classname(x)); return Qnil; /* not reached */ } @@ -211,7 +211,7 @@ num_init_copy(x, y) /* * call-seq: * +num => num - * + * * Unary Plus---Returns the receiver's value. */ @@ -225,7 +225,7 @@ num_uplus(num) /* * call-seq: * -num => numeric - * + * * Unary Minus---Returns the receiver's value, negated. */ @@ -245,7 +245,7 @@ num_uminus(num) * call-seq: * num.quo(numeric) => result * num.fdiv(numeric) => result - * + * * Equivalent to Numeric#/, but overridden in subclasses. */ @@ -262,7 +262,7 @@ static VALUE num_floor(VALUE num); /* * call-seq: * num.div(numeric) => integer - * + * * Uses / to perform division, then converts the result to * an integer. Numeric does not define the / * operator; this is left to subclasses. @@ -280,16 +280,16 @@ num_div(x, y) /* * call-seq: * num.divmod( aNumeric ) -> anArray - * + * * Returns an array containing the quotient and modulus obtained by * dividing num by aNumeric. If q, r = * x.divmod(y), then * * q = floor(float(x)/float(y)) * x = q*y + r - * + * * The quotient is rounded toward -infinity, as shown in the following table: - * + * * a | b | a.divmod(b) | a/b | a.modulo(b) | a.remainder(b) * ------+-----+---------------+---------+-------------+--------------- * 13 | 4 | 3, 1 | 3 | 1 | 1 @@ -327,7 +327,7 @@ num_divmod(x, y) /* * call-seq: * num.modulo(numeric) => result - * + * * Equivalent to * num.divmod(aNumeric)[1]. */ @@ -342,7 +342,7 @@ num_modulo(x, y) /* * call-seq: * num.remainder(numeric) => result - * + * * If num and numeric have different signs, returns * mod-numeric; otherwise, returns mod. In * both cases mod is the value @@ -370,7 +370,7 @@ num_remainder(x, y) /* * call-seq: * num.integer? -> true or false - * + * * Returns true if num is an Integer * (including Fixnum and Bignum). */ @@ -385,9 +385,9 @@ num_int_p(num) /* * call-seq: * num.abs => num or numeric - * + * * Returns the absolute value of num. - * + * * 12.abs #=> 12 * (-34.56).abs #=> 34.56 * -34.56.abs #=> 34.56 @@ -407,7 +407,7 @@ num_abs(num) /* * call-seq: * num.zero? => true or false - * + * * Returns true if num has a zero value. */ @@ -425,10 +425,10 @@ num_zero_p(num) /* * call-seq: * num.nonzero? => num or nil - * + * * Returns num if num is not zero, nil * otherwise. This behavior is useful when chaining comparisons: - * + * * a = %w( z Bb bB bb BB a aA Aa AA A ) * b = a.sort {|a,b| (a.downcase <=> b.downcase).nonzero? || a <=> b } * b #=> ["A", "a", "AA", "Aa", "aA", "BB", "Bb", "bB", "bb", "z"] @@ -447,7 +447,7 @@ num_nonzero_p(num) /* * call-seq: * num.to_int => integer - * + * * Invokes the child class's to_i method to convert * num to an integer. */ @@ -461,7 +461,7 @@ num_to_int(num) /******************************************************************** - * + * * Document-class: Float * * Float objects represent real numbers using the native @@ -482,7 +482,7 @@ rb_float_new(d) /* * call-seq: * flt.to_s => string - * + * * Returns a string containing a representation of self. As well as a * fixed or exponential form of the number, the call may return * ``NaN'', ``Infinity'', and @@ -677,9 +677,9 @@ flodivmod(x, y, divp, modp) * call-seq: * flt % other => float * flt.modulo(other) => float - * + * * Return the modulo after division of flt by other. - * + * * 6543.21.modulo(137) #=> 104.21 * 6543.21.modulo(137.24) #=> 92.9299999999996 */ @@ -710,7 +710,7 @@ flo_mod(x, y) /* * call-seq: * flt.divmod(numeric) => array - * + * * See Numeric#divmod. */ @@ -753,7 +753,7 @@ flo_divmod(x, y) * * Raises float the other power. */ - + static VALUE flo_pow(x, y) VALUE x, y; @@ -773,10 +773,10 @@ flo_pow(x, y) /* * call-seq: * num.eql?(numeric) => true or false - * + * * Returns true if num and numeric are the * same type and have equal values. - * + * * 1 == 1.0 #=> true * 1.eql?(1.0) #=> false * (1.0).eql?(1.0) #=> true @@ -794,7 +794,7 @@ num_eql(x, y) /* * call-seq: * num <=> other -> 0 or nil - * + * * Returns zero if num equals other, nil * otherwise. */ @@ -818,13 +818,13 @@ num_equal(x, y) /* * call-seq: * flt == obj => true or false - * + * * Returns true only if obj has the same value * as flt. Contrast this with Float#eql?, which * requires obj to be a Float. - * + * * 1.0 == 1 #=> true - * + * */ static VALUE @@ -891,7 +891,7 @@ rb_dbl_cmp(a, b) /* * call-seq: * flt <=> numeric => -1, 0, +1 - * + * * Returns -1, 0, or +1 depending on whether flt is less than, * equal to, or greater than numeric. This is the basis for the * tests in Comparable. @@ -962,7 +962,7 @@ flo_gt(x, y) * call-seq: * flt >= other => true or false * - * true if flt is greater than + * true if flt is greater than * or equal to other. */ @@ -1068,11 +1068,11 @@ flo_le(x, y) /* * call-seq: * flt.eql?(obj) => true or false - * + * * Returns true only if obj is a * Float with the same value as flt. Contrast this * with Float#==, which performs type conversions. - * + * * 1.0.eql?(1) #=> false */ @@ -1107,12 +1107,12 @@ flo_to_f(num) /* * call-seq: * flt.abs => float - * + * * Returns the absolute value of flt. - * + * * (-34.56).abs #=> 34.56 * -34.56.abs #=> 34.56 - * + * */ static VALUE @@ -1126,9 +1126,9 @@ flo_abs(flt) /* * call-seq: * flt.zero? -> true or false - * + * * Returns true if flt is 0.0. - * + * */ static VALUE @@ -1144,10 +1144,10 @@ flo_zero_p(num) /* * call-seq: * flt.nan? -> true or false - * + * * Returns true if flt is an invalid IEEE floating * point number. - * + * * a = -1.0 #=> -1.0 * a.nan? #=> false * a = 0.0/0.0 #=> NaN @@ -1157,7 +1157,7 @@ flo_zero_p(num) static VALUE flo_is_nan_p(num) VALUE num; -{ +{ double value = RFLOAT(num)->value; return isnan(value) ? Qtrue : Qfalse; @@ -1166,10 +1166,10 @@ flo_is_nan_p(num) /* * call-seq: * flt.infinite? -> nil, -1, +1 - * + * * Returns nil, -1, or +1 depending on whether flt * is finite, -infinity, or +infinity. - * + * * (0.0).infinite? #=> nil * (-1.0/0.0).infinite? #=> -1 * (+1.0/0.0).infinite? #=> 1 @@ -1178,7 +1178,7 @@ flo_is_nan_p(num) static VALUE flo_is_infinite_p(num) VALUE num; -{ +{ double value = RFLOAT(num)->value; if (isinf(value)) { @@ -1191,17 +1191,17 @@ flo_is_infinite_p(num) /* * call-seq: * flt.finite? -> true or false - * + * * Returns true if flt is a valid IEEE floating * point number (it is not infinite, and nan? is * false). - * + * */ static VALUE flo_is_finite_p(num) VALUE num; -{ +{ double value = RFLOAT(num)->value; #if HAVE_FINITE @@ -1218,9 +1218,9 @@ flo_is_finite_p(num) /* * call-seq: * flt.floor => integer - * + * * Returns the largest integer less than or equal to flt. - * + * * 1.2.floor #=> 1 * 2.0.floor #=> 2 * (-1.2).floor #=> -2 @@ -1244,10 +1244,10 @@ flo_floor(num) /* * call-seq: * flt.ceil => integer - * + * * Returns the smallest Integer greater than or equal to * flt. - * + * * 1.2.ceil #=> 2 * 2.0.ceil #=> 2 * (-1.2).ceil #=> -1 @@ -1271,18 +1271,18 @@ flo_ceil(num) /* * call-seq: * flt.round => integer - * + * * Rounds flt to the nearest integer. Equivalent to: - * + * * def round * return (self+0.5).floor if self > 0.0 * return (self-0.5).ceil if self < 0.0 * return 0 * end - * + * * 1.5.round #=> 2 * (-1.5).round #=> -2 - * + * */ static VALUE @@ -1307,7 +1307,7 @@ flo_round(num) * flt.to_i => integer * flt.to_int => integer * flt.truncate => integer - * + * * Returns flt truncated to an Integer. */ @@ -1332,11 +1332,11 @@ flo_truncate(num) /* * call-seq: * num.floor => integer - * + * * Returns the largest integer less than or equal to num. * Numeric implements this by converting anInteger * to a Float and invoking Float#floor. - * + * * 1.floor #=> 1 * (-1).floor #=> -1 */ @@ -1352,12 +1352,12 @@ num_floor(num) /* * call-seq: * num.ceil => integer - * + * * Returns the smallest Integer greater than or equal to * num. Class Numeric achieves this by converting * itself to a Float then invoking * Float#ceil. - * + * * 1.ceil #=> 1 * 1.2.ceil #=> 2 * (-1.2).ceil #=> -1 @@ -1374,7 +1374,7 @@ num_ceil(num) /* * call-seq: * num.round => integer - * + * * Rounds num to the nearest integer. Numeric * implements this by converting itself to a * Float and invoking Float#round. @@ -1390,7 +1390,7 @@ num_round(num) /* * call-seq: * num.truncate => integer - * + * * Returns num truncated to an integer. Numeric * implements this by converting its value to a float and invoking * Float#truncate. @@ -1407,7 +1407,7 @@ num_truncate(num) /* * call-seq: * num.step(limit, step ) {|i| block } => num - * + * * Invokes block with the sequence of numbers starting at * num, incremented by step on each call. The loop * finishes when the value to be passed to the block is greater than @@ -1421,12 +1421,12 @@ num_truncate(num) * > operator to compare the counter against * limit, and increments itself using the + * operator. - * + * * 1.step(10, 2) { |i| print i, " " } * Math::E.step(Math::PI, 0.2) { |f| print f, " " } - * + * * produces: - * + * * 1 3 5 7 9 * 2.71828182845905 2.91828182845905 3.11828182845905 */ @@ -1722,7 +1722,7 @@ rb_num2ull(val) * * Integer is the basis for the two concrete classes that * hold whole numbers, Bignum and Fixnum. - * + * */ @@ -1749,7 +1749,7 @@ int_to_i(num) /* * call-seq: * int.integer? -> true - * + * * Always returns true. */ @@ -1764,9 +1764,9 @@ int_int_p(num) * call-seq: * int.next => integer * int.succ => integer - * + * * Returns the Integer equal to int + 1. - * + * * 1.next #=> 2 * (-1).next #=> 0 */ @@ -1785,10 +1785,10 @@ int_succ(num) /* * call-seq: * int.chr => string - * + * * Returns a string containing the ASCII character represented by the * receiver's value. - * + * * 65.chr #=> "A" * ?a.chr #=> "a" * 230.chr #=> "\346" @@ -1808,14 +1808,14 @@ int_chr(num) } /******************************************************************** - * + * * Document-class: Fixnum * * A Fixnum holds Integer values that can be * represented in a native machine word (minus 1 bit). If any operation * on a Fixnum exceeds this range, the value is * automatically converted to a Bignum. - * + * * Fixnum objects have immediate value. This means that * when they are assigned or passed as parameters, the actual object is * passed, rather than a reference to that object. Assignment does not @@ -1935,10 +1935,10 @@ rb_fix2str(x, base) /* * call-seq: * fix.to_s( base=10 ) -> aString - * + * * Returns a string containing the representation of fix radix * base (between 2 and 36). - * + * * 12345.to_s #=> "12345" * 12345.to_s(2) #=> "11000000111001" * 12345.to_s(8) #=> "30071" @@ -1968,7 +1968,7 @@ fix_to_s(argc, argv, x) * fix + numeric => numeric_result * * Performs addition: the class of the resulting object depends on - * the class of numeric and on the magnitude of the + * the class of numeric and on the magnitude of the * result. */ @@ -1998,7 +1998,7 @@ fix_plus(x, y) * fix - numeric => numeric_result * * Performs subtraction: the class of the resulting object depends on - * the class of numeric and on the magnitude of the + * the class of numeric and on the magnitude of the * result. */ @@ -2028,7 +2028,7 @@ fix_minus(x, y) * fix * numeric => numeric_result * * Performs multiplication: the class of the resulting object depends on - * the class of numeric and on the magnitude of the + * the class of numeric and on the magnitude of the * result. */ @@ -2095,13 +2095,13 @@ fixdivmod(x, y, divp, modp) * call-seq: * fix.quo(numeric) => float * fix.fdiv(numeric) => float - * + * * Returns the floating point result of dividing fix by * numeric. - * + * * 654321.quo(13731) #=> 47.6528293642124 * 654321.quo(13731.24) #=> 47.6519964693647 - * + * */ static VALUE @@ -2120,7 +2120,7 @@ fix_quo(x, y) * fix.div(numeric) => numeric_result * * Performs division: the class of the resulting object depends on - * the class of numeric and on the magnitude of the + * the class of numeric and on the magnitude of the * result. */ @@ -2162,7 +2162,7 @@ fix_mod(x, y) /* * call-seq: * fix.divmod(numeric) => array - * + * * See Numeric#divmod. */ static VALUE @@ -2270,7 +2270,7 @@ fix_equal(x, y) /* * call-seq: * fix <=> numeric => -1, 0, +1 - * + * * Comparison---Returns -1, 0, or +1 depending on whether fix is * less than, equal to, or greater than numeric. This is the * basis for the tests in Comparable. @@ -2517,16 +2517,16 @@ fix_rshift(x, y) /* * call-seq: * fix[n] => 0, 1 - * + * * Bit Reference---Returns the nth bit in the binary * representation of fix, where fix[0] is the least * significant bit. - * + * * a = 0b11001100101010 * 30.downto(0) do |n| print a[n] end - * + * * produces: - * + * * 0000000000000000011001100101010 */ @@ -2560,9 +2560,9 @@ fix_aref(fix, idx) /* * call-seq: * fix.to_f -> float - * + * * Converts fix to a Float. - * + * */ static VALUE @@ -2579,12 +2579,12 @@ fix_to_f(num) /* * call-seq: * fix.abs -> aFixnum - * + * * Returns the absolute value of fix. - * + * * -12345.abs #=> 12345 * 12345.abs #=> 12345 - * + * */ static VALUE @@ -2601,13 +2601,13 @@ fix_abs(fix) /* * call-seq: * fix.id2name -> string or nil - * + * * Returns the name of the object whose symbol id is fix. If * there is no symbol in the symbol table with this value, returns * nil. id2name has nothing to do with the * Object.id method. See also Fixnum#to_sym, * String#intern, and class Symbol. - * + * * symbol = :@inst_var #=> :@inst_var * id = symbol.to_i #=> 9818 * id.id2name #=> "@inst_var" @@ -2626,10 +2626,10 @@ fix_id2name(fix) /* * call-seq: * fix.to_sym -> aSymbol - * + * * Returns the symbol whose integer value is fix. See also * Fixnum#id2name. - * + * * fred = :fred.to_i * fred.id2name #=> "fred" * fred.to_sym #=> :fred @@ -2651,10 +2651,10 @@ fix_to_sym(fix) /* * call-seq: * fix.size -> fixnum - * + * * Returns the number of bytes in the machine representation * of a Fixnum. - * + * * 1.size #=> 4 * -1.size #=> 4 * 2147483647.size #=> 4 @@ -2670,14 +2670,14 @@ fix_size(fix) /* * call-seq: * int.upto(limit) {|i| block } => int - * + * * Iterates block, passing in integer values from int * up to and including limit. - * + * * 5.upto(10) { |i| print i, " " } - * + * * produces: - * + * * 5 6 7 8 9 10 */ @@ -2708,15 +2708,15 @@ int_upto(from, to) /* * call-seq: * int.downto(limit) {|i| block } => int - * + * * Iterates block, passing decreasing values from int * down to and including limit. - * + * * 5.downto(1) { |n| print n, ".. " } * print " Liftoff!\n" - * + * * produces: - * + * * 5.. 4.. 3.. 2.. 1.. Liftoff! */ @@ -2747,16 +2747,16 @@ int_downto(from, to) /* * call-seq: * int.times {|i| block } => int - * + * * Iterates block int times, passing in values from zero to * int - 1. - * + * * 5.times do |i| * print i, " " * end - * + * * produces: - * + * * 0 1 2 3 4 */ @@ -2787,9 +2787,9 @@ int_dotimes(num) /* * call-seq: * fix.zero? => true or false - * + * * Returns true if fix is zero. - * + * */ static VALUE