aboutsummaryrefslogtreecommitdiffstats
path: root/numeric.c
Commit message (Collapse)AuthorAgeFilesLines
* * numeric.c: provides predicate real? instead of scalar?.tadf2008-09-161-4/+4
| | | | | | | | | | * complex.c: follows the above change. * lib/cmath.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h (DBL2NUM): renamed from DOUBLE2NUM.matz2008-09-051-39/+39
| | | | | | | a patch from Tadashi Saito <shiba at mail2.accsnet.ne.jp> in [ruby-dev:36102]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * complex.c ({nucomp,numeric}_rect): new.tadf2008-08-291-0/+3
| | | | | | | | | | | | | | | | | | | | | | | * complex.c: added some aliases (::rectangular, ::rect, #rectangular, #rect, #phase, #magnitude). * complex.c (string_to_c_internal): should not strip any null bytes. * rational.c (string_to_r_internal): ditto. * rational.c (i_gcd): reverted to nurat 0.0.2's one. * numeric.c: added an alias (#magnitude). * test/ruby/test_complex.rb: added assertions. * test/ruby/test_rational.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h (rb_intern_const): tiny optimization.nobu2008-08-161-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (check_uint): fix wrong message.usa2008-07-181-8/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (check_uint, rb_num2uint, rb_fix2uint): fixed wrong checkusa2008-07-181-14/+15
| | | | | | | | about 64bit positive value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (check_uint, rb_num2uint, rb_fix2uint): strict check.usa2008-07-171-10/+19
| | | | | | | | fixed [ruby-dev:33683] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (check_uint, rb_num2uint, rb_fix2uint): proper check.usa2008-07-041-4/+10
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (rb_num2uint, rb_fix2uint): typo.usa2008-07-031-2/+2
| | | | | | | * ChangeLog: format. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (check_uint, rb_num2uint): also needs checking negativeusa2008-07-031-8/+4
| | | | | | | | value. see [ruby-dev:33683] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (num_coerce): call rb_Float(x) first. don't depend onakr2008-06-301-1/+3
| | | | | | | evaluation order of function arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (flo_round): get rid of overflow.nobu2008-06-211-5/+10
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h (CONST_ID): constant ID cache for non-gcc.nobu2008-06-091-0/+2
| | | | | | | * *.c: no cache in init functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c: "%" is required before PRI?VALUE.akr2008-05-271-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (num_div): should raise ZeroDivisionError.matz2008-05-271-1/+6
| | | | | | | | | * numeric.c (fix_divide): ditto. * test/ruby/test_numeric.rb (TestNumeric::test_divmod): avoid ZeroDivisionError in tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (num_fdiv): fallback to_f should always return floatmatz2008-05-271-1/+15
| | | | | | result. should not use #quo that may return rational. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (check_int): use PRIxVALUE format specifier.matz2008-05-271-12/+4
| | | | | | * numeric.c (check_uint, rb_num2fix, int_chr): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (bit_coerce): float should not be a valid operand ofmatz2008-05-071-5/+9
| | | | | | bitwise operations. [ruby-dev:34583] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (fix_divide): float division should floor() beforematz2008-05-071-1/+1
| | | | | | rounding into integer. [ruby-dev:34584] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (sym_to_i): remove obsolete method. preparation formatz2008-05-071-49/+0
| | | | | | | | | | symbol GC. * numeric.c (fix_to_sym): ditto. * numeric.c (fix_id2name): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_fdiv): flo.fdiv(NaN) should result NaN.matz2008-05-071-13/+4
| | | | | | | | | | | | | | * numeric.c (num_quo): renamed and moved from bignum.c. [ruby-dev:34582] * bignum.c (rb_big_fdiv): update RDoc description * rational.c (nurat_s_new_m): small refactoring. * bignum.c (rb_big2dbl): no need for forceful warning when converting to float. overflow is a nature of float values. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_divide), numeric.c (fix_divide): check for resultnobu2008-05-011-10/+12
| | | | | | | domain. [ruby-dev:34559] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16258 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c: cancelled recent changes (except to remove rdiv).tadf2008-04-071-28/+22
| | | | | | | | | | * bignum.c: ditto. * bignum.c: added rb_big_idiv. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (num_quo): RDoc updated.matz2008-04-031-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (Init_Bignum): rdiv method removed. [ruby-dev:34242]matz2008-04-031-20/+6
| | | | | | | | | | | | * complex.c (nucomp_quo): ditto. * numeric.c (num_rdiv): ditto. * rational.c (nurat_div): ditto. * complex.c (nucomp_fdiv): fdiv implementation restored. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (num_rdiv): should always return rational number.matz2008-04-021-29/+40
| | | | | | | | | | | * rational.c (nurat_add, nurat_sub, nurat_mul, nurat_fdiv, nurat_cmp): use rb_num_coerce_bin(). * rational.c (nurat_division): does / and rdiv. * .gdbinit (rp): no longer use rb_p(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (num_quo): should convert its operand to Rational.matz2008-03-311-2/+2
| | | | | | | | | * rational.c (string_to_r_strict): should raise TypeError. * bignum.c (Init_Bignum): should not redefine Bignum#div. Numeric#div will do. [ruby-dev:34066] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* both complex and rational are now builtin classes.tadf2008-03-161-6/+63
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (flo_divmod): remvoed unused variable.nobu2008-03-141-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (fix_divmod): should return integer division. [ruby-dev:34006]matz2008-03-131-11/+18
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (fix_coerce): try conversion before type check.nobu2008-03-111-9/+19
| | | | | | | [ruby-core:15838] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix doc.akr2008-03-091-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (fix_to_s): avoid rb_scan_args() when no argumentmatz2008-03-051-4/+7
| | | | | | | | | | | | | | | | | | | | | | given. * bignum.c (rb_big_to_s): ditto. * enum.c (enum_first): ditto. * eval_jump.c (rb_f_catch): ditto. * io.c (rb_obj_display): ditto. * class.c (rb_obj_singleton_methods): ditto. * object.c (rb_class_initialize): ditto. * random.c (rb_f_srand): ditto. * range.c (range_step): ditto. * re.c (rb_reg_s_last_match): ditto. * string.c (rb_str_to_i): ditto. * string.c (rb_str_each_line): ditto. * string.c (rb_str_chomp_bang): ditto. * string.c (rb_str_sum): ditto. * string.c (str_modifiable): declare inline. * string.c (str_independent): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (rb_num_coerce_bin): add ID argument to specifymatz2008-02-121-31/+31
| | | | | | | | | | | | caller's method name. [ruby-dev:33663] * numeric.c (rb_num_coerce_cmp): ditto. * numeric.c (rb_num_coerce_relop): ditto. * ext/bigdecimal/bigdecimal.c (DoSomeOne): add function name argument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_usascii_new{,2}: defined.naruse2008-01-251-6/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | (rb_str_new): set US-ASCII and ENC_CODERANGE_7BIT when empty string. * encoding.c (rb_usascii_encoding, rb_usascii_encindex): defined. (rb_enc_inspect, enc_name, rb_locale_charmap, rb_enc_name_list_i): use rb_str_ascii_new. * array.c (recursive_join, inspect_ary): ditto. * object.c (nil_to_s, nil_inspect, true_to_s, false_to_s, rb_mod_to_s): ditto. * hash.c (inspect_hash, rb_hash_inspect, rb_f_getenv, env_fetch, env_clear, env_to_s, env_inspect): ditto. * numeric.c (flo_to_s, int_chr, rb_fix2str): ditto. * bignum.c (rb_big2str): ditto. * file.c (rb_file_ftype, rb_file_s_dirname, rb_file_s_extname, file_inspect_join, Init_file): ditto. * test/ruby/test_ruby_m17n.rb: add checks for encoding of string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (fix_quo): typo. a patch from Shin-ichiro HARAusa2008-01-161-1/+1
| | | | | | | | <sinara AT blade.nagaokaut.ac.jp> in [ruby-dev:33130] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * $Date$ keyword removed to avoid inclusion of locale dependentakr2008-01-061-1/+0
| | | | | | | string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix typos.akr2007-12-311-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * pack.c (pack_pack): use NUM2LONG instead of NUM2INT.usa2007-12-241-3/+3
| | | | | | | | | | | * numeric.c (fix_lshift, fix_aref): use SIZEOF_LONG instead of SIZEOF_VALUE. * bignum.c (big2ulong, rb_big_aref): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * proc.c (method_name): preserve Symbol's encoding.matz2007-12-241-2/+2
| | | | | | * numeric.c (fix_id2name): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enable several rdoc.akr2007-12-241-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h, encoding.c, re.c, io.c, parse.y, numeric.c,akr2007-12-221-1/+1
| | | | | | | | | ruby.c, transcode.c: rename rb_ascii_encoding. to rb_ascii8bit_encoding. rb_ascii_encoding is ambiguous with ASCII-8BIT and US-ASCII. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * encoding.c (rb_ascii_encoding): renamed from previousmatz2007-12-211-1/+1
| | | | | | rb_default_encoding(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_io_s_read): allow specifying encoding explicitly.matz2007-12-211-0/+1
| | | | | | | | | | | | * io.c (rb_io_binmode): specifies encoding to ASCII-8BIT (binary). * io.c (rb_io_s_read): IO should be in binary mode when offset is specified. * encoding.c (rb_to_encoding): returns default encoding if no corresponding encoding found. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * regerror.c, string.c, io.c, lib/getoptlong.rb, lib/net/imap.rb,akr2007-12-211-1/+1
| | | | | | | | | | | compile.c, sprintf.c, parse.y, ext/win32ole/win32ole.c, ext/tk/sample/demos-en/entry3.rb, ext/tk/lib/tcltk.rb, ext/openssl/ossl_bn.c, numeric.c, vm.c, benchmark/bm_so_meteor_contest.rb, bignum.c, ruby.c: don't "illegal" for non law violation context. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h: rename RFloat#double_value -> float_value.ko12007-11-201-1/+1
| | | | | | | | * numeric.c, parse.y: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (round): fallback definition.nobu2007-11-131-6/+19
| | | | | | | | * numeric.c (flo_divmod, flo_round): use round() always. [ruby-dev:32269] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h: introduce 2 macros:ko12007-11-131-88/+88
| | | | | | | | | | | | | | | RFLOAT_VALUE(v), DOUBLE2NUM(dbl). Rename RFloat#value -> RFloat#double_value. Do not touch RFloat#double_value directly. * bignum.c, insns.def, marshal.c, math.c, numeric.c, object.c, pack.c, parse.y, process.c, random.c, sprintf.c, string.c, time.c: apply above changes. * ext/dl/mkcallback.rb, ext/json/ext/generator/generator.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (flodivmod): work around for inifinity.nobu2007-11-131-1/+11
| | | | | | | | * numeric.c (flo_divmod): work around for platforms have no round(). [ruby-dev:32247] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (flo_divmod): round to the nearest integer. [ ruby-Bugs-14540 ]shyouhei2007-11-121-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e