aboutsummaryrefslogtreecommitdiffstats
path: root/bignum.c
Commit message (Collapse)AuthorAgeFilesLines
* * bignum.c (rb_big2ull): fix 32bit platform breakage. we mustkosaki2011-11-141-2/+2
| | | | | | | | | | not assume sizeof(VALUE) == sizeof(LONG_LONG). * test/-ext-/num2int/test_num2int.rb (class TestNum2int): fix false assumption on 32bit platform. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big2ull): fix off-by-twice bug of NUM2ULL.kosaki2011-11-141-2/+8
| | | | | | | | | * test/-ext-/num2int/test_num2int.rb (class TestNum2int): fix a testcase too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (check_uint): fix off-by-one bug of NUM2UINT.kosaki2011-11-141-3/+4
| | | | | | | | | | | | | | * bignum.c (rb_big2ulong): fix off-by-one bug of NUM2ULONG. * test/-ext-/num2int/test_num2int.rb: add a testcase for NUM2INT() NUM2UINT(), NUM2LONG(), NUM2ULONG(), NUM2LL and NUM2ULL(). * ext/-test-/num2int/depend: ditto. * ext/-test-/num2int/extconf.rb: ditto. * ext/-test-/num2int/num2int.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_divide): raise ZeroDivisionError if divisor isnobu2011-10-271-1/+3
| | | | | | zero, as well as Fixnum. [ruby-core:40429] [Bug #5490] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * use RB_TYPE_P which is optimized for constant types, instead ofnobu2011-09-291-8/+8
| | | | | | comparison with TYPE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (bit_coerce): A Fixnum and a Bignum are only permitted formrkn2011-08-291-3/+3
| | | | | | | | | | bitwise arithmetic with a Fixnum. #1792 * test/ruby/test_fixnum.rb: add tests for the above change. * bignum.c (bit_coerce): A Fixnum and a Bignum are only permitted for bitwise arithmetic with a Bignum. #1792 * test/ruby/test_bignum.rb: add tests for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigsub_int): add RB_GC_GUARD. This patch is made bymrkn2011-07-151-0/+3
| | | | | | | Makoto Kishimoto. fixes #4223 [ruby-dev:42907] * bignum.c (bigadd_int): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: declare internal functions here.akr2011-06-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | * node.h: declare NODE dependent internal functions here. * iseq.h: declare rb_iseq_t dependent internal functions here. * vm_core.h: declare rb_thread_t dependent internal functions here. * bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c, enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c, iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y, proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c, thread.c, time.c, transcode.c, variable.c, vm.c, tool/compile_prelude.rb: don't declare internal functions declared in above headers. include above headers if required. Note that rb_thread_mark() was declared as void rb_thread_mark(rb_thread_t *th) in cont.c but defined as void rb_thread_mark(void *ptr) in vm.c. Now it is declared as the later in internal.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigmul1_toom3): remove unused variable.nobu2011-05-291-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (flo_round): fix for negative value.nobu2011-05-291-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (dump_bignum, bigmul1_balance, big_split, biglsh_bang,mrkn2011-05-221-21/+286
| | | | | | | | bigrsh_bang, big_split3, bigmul1_toom3, bigmul0): implement Toom3 (Toom-Cook) multiplication. * include/ruby/defines.h: add format prefixes for BDIGIT and BDIGIT_DBL. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_str_to_inum): get rid of too huge alloca().kosaki2011-01-271-2/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigmul1_karatsuba): avoid overflow that make assertionmatz2011-01-071-6/+6
| | | | | | | fail in certain case. this patch is contributed from Ray Chason <chasonr at gmail.com> in personal communication. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c: parenthesize macro arguments.akr2010-12-021-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big2long, rb_big2ulong): rb2ulong() returns VALUE, butusa2010-10-271-3/+3
| | | | | | | | | | its real range is ulong. So, if the size of VALUE is bigger than ulong, upper bits are always zero even if the actual value is negative. fixed #3490 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rb_genrand_ulong_limited): renamed fromnaruse2010-09-101-4/+3
| | | | | | | | | | rb_rand_internal and now this is public API. * include/ruby/ruby.h (rb_genrand_ulong_limited): added. * bignum.c (big_sparse_p): use rb_genrand_ulong_limited. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_eq): never equal to infinity.nobu2010-08-031-1/+1
| | | | | | | | | [ruby-core:31603] * rational.c (nurat_div): hack for integral float divisor. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (big_op): comparison of bignum and infinity has returned 1mame2010-08-011-2/+3
| | | | | | or -1, but it must return boolean. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * removed trailing spaces.nobu2010-05-291-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c: Documentation: change => in call-seq to ->.marcandre2010-05-171-22/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Harmonize "#=>" in examples. [ruby-core:30206] * bignum.c: ditto * class.c: ditto * compar.c: ditto * cont.c: ditto * dir.c: ditto * encoding.c: ditto * enum.c: ditto * enumerator.c: ditto * error.c: ditto * eval.c: ditto * file.c: ditto * gc.c: ditto * io.c: ditto * load.c: ditto * marshal.c: ditto * math.c: ditto * numeric.c: ditto * object.c: ditto * pack.c: ditto * proc.c: ditto * process.c: ditto * random.c: ditto * range.c: ditto * re.c: ditto * ruby.c: ditto * signal.c: ditto * sprintf.c: ditto * string.c: ditto * struct.c: ditto * thread.c: ditto * time.c: ditto * transcode.c: ditto * variable.c: ditto * vm_eval.c: ditto * vm_method.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigmul1_karatsuba): suppress a warning.nobu2010-04-251-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigmul1_karatsuba): fix calculation order to preventmame2010-04-201-15/+18
| | | | | | underflow. [ruby-core:29088] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c, node.h, strftime.c, enc/trans/utf8_mac.trans: added explicit ↵muraken2010-03-251-1/+1
| | | | | | casts for supplessing warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_pack): use DIGSPERLONG and BITSPERDIG.akr2010-03-071-4/+4
| | | | | | | (rb_big_unpack): use DIGSPERLONG. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add comment.akr2010-03-041-0/+14
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * pack.c: check assuption on QUAD_SIZE and SIZEOF_LONG.akr2010-02-271-0/+4
| | | | | | | * bignum.c: check assuption on SIZEOF_LONG and SIZEOF_BDIGITS. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * pack.c: fix q and Q for big endian environments which have noakr2010-02-261-0/+83
| | | | | | | | | | | | | | | | 8 bytes integer type. (pack_pack): use rb_big_pack. (pack_unpack): use rb_big_unpack. * include/ruby/intern.h (rb_big_pack): declared. (rb_big_unpack): ditto. * bignum.c (rb_big_pack): new function. (rb_big_unpack): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c: fix rb_quad_pack and rb_quad_unpack for environmentsakr2010-02-261-12/+18
| | | | | | | | | | | | | which don't have 8bytes integer type. This still depends on little endian. (rb_quad_pack): use quad_buf_complement. don't raise for large values. (rb_quad_unpack): use quad_buf_complement. (quad_buf_complement): new function extracted frm rb_quad_pack. add one after bitwise negation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * pack.c (QUAD_SIZE): it should be always 8.akr2010-02-261-3/+3
| | | | | | | | * bignum.c (rb_quad_pack): use LONG_LONG version only if SIZEOF_LONG_LONG == QUAD_SIZE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (big_op): remove unused variables.naruse2010-02-051-2/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (big_gt, big_ge, big_lt, big_ge): added Bignum#>, >=, < andmame2010-02-041-0/+111
| | | | | | <= to allow to compare with BigDecimal. [ruby-dev:40167] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ext/bigdecimal/bigdecimal.c (BigDecimal_to_i): update RDoc tomatz2010-01-281-0/+2
| | | | | | | | | | | denote that #to_i raises FloatDomainError for Inf and NaN. * ext/bigdecimal/bigdecimal.c (BigDecimal_to_i): fast #to_i using BigDecimal_split(). * bignum.c (conv_digit): use faster ISDIGIT() assuming ASCII. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigsub_int): remove nonsense loop.mame2010-01-181-2/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add Float::INFINITY and Float::NAN.naruse2009-12-291-1/+1
| | | | | | | | | | | | | | | | | | | | * numeric.c (Init_Numeric): Add Float::INFINITY and Float::NAN. [ruby-dev:1657] [ruby-dev:4760] [ruby-list:7023] [ruby-list:46690] [ruby-core:26632] [ruby-talk:41352] [ruby-talk:203333] * include/ruby/defines.h (INFINITY): defined. * include/ruby/defines.h (NAN): defined. * include/ruby/util.h (ruby_div0): removed. * numeric.c (fix_pow): use INFINITY and NAN instead of ruby_div0(1.0). * marshal.c (r_object0): ditto. * bignum.c (big_fdiv): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * removed spaces just before tabs.nobu2009-11-261-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c: rdoc for <=>, casecmpmarcandre2009-10-281-1/+1
| | | | | | | | | | | | * bignum.c: rdoc for <=> * file.c: ditto * time.c: ditto * compar.c: rdoc git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (big_split): fix off-by-one error. [ruby-dev:39501]mame2009-10-171-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix rdoc.akr2009-10-121-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigmul1_single): suppress a warning.nobu2009-09-131-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/st.h (st_hash_func): use st_index_t.nobu2009-09-081-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_idiv): added rdoc.nobu2009-09-041-1/+10
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_div, rb_big_idiv): fixed indent.nobu2009-09-041-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigmul1_single): new function specialized respect toakr2009-08-301-0/+19
| | | | | | | | | multiply two single digit bignums. (bigmul0): use bigmul1_single. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_clone, bigmul1_normal, bigdivrem): trivialnobu2009-08-251-26/+29
| | | | | | | | | | optimization. * bignum.c (big2dbl): truncates zero digits to get rid of possible underflow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (flo_pow,fix_pow): may return complex number.tadf2009-08-161-0/+2
| | | | | | | | * bignum.c (rb_big_pow): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * insns.def, vm.c, vm_insnhelper.c, vm_insnhelper.h: checkko12009-08-121-0/+1
| | | | | | | | | | | | definition of (classes)#=== for case/when optimization. Fix Bug #1376 [ruby-core:23190]. * string.c (Init_String), bignum.c (Init_Bignum), numeric.c (Init_Numeric): define String#===, Symbol#===, Bignum#===, Fixnum#===, Float#=== as same as (classes)#==. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_cmp, bigsub, big_real_len, bigmul1_normal,mame2009-08-091-16/+32
| | | | | | | bigmul1_balance, big_split): remove BDIGITS() inside of the loops. same as r24444. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigzero_p): removing BDIGITS() inside of thematz2009-08-081-1/+3
| | | | | | | loop. inspired by Hitohiro Kanai's blog entry <http://d.hatena.ne.jp/CanI/20090807/1249657492>. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * suppressed shorten-64-to-32 warnings.nobu2009-07-181-6/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_new, rb_bigzero_p), range.c (rb_range_values):nobu2009-07-161-0/+12
| | | | | | | added for random.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e