aboutsummaryrefslogtreecommitdiffstats
path: root/numeric.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix for r33811.naruse2011-11-221-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (ruby_float_step): improve floating point calculations.naruse2011-11-221-4/+15
| | | | | | | | | | | | | | [ruby-core:35753] [Bug #4576] * numeric.c (ruby_float_step): correct the error of floating point numbers on the excluding case. patched by Masahiro Tanaka [ruby-core:39608] * numeric.c (ruby_float_step): use the end value when the current value is greater than or equal to the end value. patched by Akira Tanaka [ruby-core:39612] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (rb_fix2ushort): fix typo. use num rb_num2ushort()kosaki2011-11-141-1/+1
| | | | | | | | instead of num2uint(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h: add NUM2SHORT(), NUM2USHORT() macros.kosaki2011-11-141-0/+74
| | | | | | | | | | | * numeric.c: ditto. * test/-ext-/num2int/test_num2int.rb: add testcases for NUM2SHORT(). * ext/-test-/num2int/num2int.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (check_uint): fix off-by-one bug of NUM2UINT.kosaki2011-11-141-1/+1
| | | | | | | | | | | | | | * 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
* * numeric.c (rb_infinity, rb_nan): aggregated member initializersnobu2011-10-231-4/+4
| | | | | | need braces. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (rb_infinity, rb_nan): use union to prevent bus errorngoto2011-10-211-4/+4
| | | | | | | | caused by misalignment. [Bug #5469] [ruby-dev:44657] * include/ruby/missing.h (INFINITY, NAN): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33502 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert r33407; half-baked patch.naruse2011-10-051-19/+4
| | | | | | "* numeric.c (ruby_float_step): improve floating point calculations." git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (ruby_float_step): improve floating point calculations.naruse2011-10-051-4/+19
| | | | | | | | | | | | | | [ruby-core:35753] [Bug #4576] * numeric.c (ruby_float_step): correct the error of floating point numbers on the excluding case. patched by Masahiro Tanaka [ruby-core:39608] * numeric.c (ruby_float_step): use the end value when the current value is greater than or equal to the end value. patched by Akira Tanaka [ruby-core:39612] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * use RB_TYPE_P which is optimized for constant types, instead ofnobu2011-09-291-5/+5
| | | | | | comparison with TYPE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "* numeric.c (ruby_float_step): Avoid error on i386 and amd64."naruse2011-09-161-3/+1
| | | | | | This reverts commit r33285 because of the message of r33284. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (ruby_float_step): Avoid error on i386 and amd64.marcandre2011-09-161-1/+3
| | | | | | Patch by Vit Ondruch. Issue #4576 [rubyspec:a9525edcd] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "* numeric.c (ruby_float_step): Avoid error on i386 and amd64."naruse2011-09-161-3/+1
| | | | | | | | | | | r33282 challenged the precision of floating point but: * Ruby keeps it as platform dependent * amd64 won't get this issue because compilers for amd64 uses SSE2 to calculate floating point numbers instead of x87 FPU. * this change won't fix the issue under -O * this commit has no test for the changed behavior git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33284 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (ruby_float_step): Avoid error on i386 and amd64.marcandre2011-09-151-1/+3
| | | | | | Patch by Vit Ondruch. Issue #4576. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33282 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (dbl2ival): Fix Float#divmod and #round for 32 bit platformmarcandre2011-09-051-1/+1
| | | | | | part 1 of [bug #5276] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (flo_round): Fix criteria for 32 bits platformmarcandre2011-09-051-5/+5
| | | | | | part 2 of [bug #5276] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (flo_round): Make Float#round round big values [bug #5272]marcandre2011-09-041-34/+16
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c: Extract integer rounding into int_round_0marcandre2011-09-041-32/+41
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (int_round): Integer#round always returns an Integer [Bug #5271]marcandre2011-09-041-4/+13
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (flo_round): substitute machine dependent magic number.nobu2011-09-011-5/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (flo_round): Avoid overflow by optimizing for trivial casesmarcandre2011-08-311-6/+28
| | | | | | [Bug #5227] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (bit_coerce): A Fixnum and a Bignum are only permitted formrkn2011-08-291-4/+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
* * numeric.c (int_round): Fix Integer#round [ruby-core:39096]marcandre2011-08-241-1/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c: Rdoc fixmarcandre2011-08-241-3/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (rb_infinity, rb_nan): use WORDS_BIGENDIAN to get endian.ngoto2011-08-051-2/+2
| | | | | | | fix [Bug #5160] [ruby-dev:44356] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (rb_num2ull): use FIX2LONG instead of FIX2ULONG. seeusa2011-07-111-1/+1
| | | | | | | rb_num2ulong(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (ULLONG_MAX): fallback definition.nobu2011-07-091-0/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (rb_num2ull): use own switch sentense.naruse2011-07-071-2/+35
| | | | | | Current implementation can't convert 18446744073709551615. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: declare internal functions here.akr2011-06-171-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | * 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
* * numeric.c (rb_enc_uint_chr): fix message format. Bug#4869nobu2011-06-111-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/missing.h, numeric.c (round): moved prototype of round()usa2011-06-031-2/+0
| | | | | | | | from numeric.c to missing.h. (note: round() is C99 feature, so ruby provides it if not exists in C runtime.) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * insns.def (opt_mult): as r31805, volatile it.naruse2011-05-301-1/+1
| | | | | | | | | | Without this, clang -O fails calculation. * numeric.c (fix_mul): ditto. * rational.c (f_imul): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (int_pow): make sure to assign the result of x * z.naruse2011-05-301-1/+1
| | | | | | If xz is optimized out, the value won't overflow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* revert r31783.nobu2011-05-291-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (flo_round): use absolute value as divisor.nobu2011-05-291-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c: add #include "interna.h" for rb_big_uminus() prototype.nagachika2011-05-291-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (flo_round): fix for negative value.nobu2011-05-291-2/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * remove trailing spaces.nobu2011-05-151-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (flo_coerce): fix a typo in documentation.nagachika2011-05-131-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add #flo_coerce documentation.shyouhei2011-05-131-1/+9
| | | | | | | | Signed-off-by: URABE, Shyouhei <shyouhei@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (int_ord): remove K&R style.naruse2011-05-091-2/+1
| | | | | | patched by Daehyub Kim. https://github.com/ruby/ruby/pull/17 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (ruby_float_step): wrong loop condition.usa2011-04-141-1/+1
| | | | | | | | | | fixes [ruby-core:35753], reported by Joey Zhou. * test/ruby/test_range.rb (TestRange#test_step_ruby_core_35753): test above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (flo_round): fix inaccurate results.nobu2011-03-221-1/+12
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (flo_round): use pow instead of while-loop. fixes #4510naruse2011-03-221-5/+2
| | | | | | patched by Alex Young [ruby-core:35526] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (Init_Numeric): fixed a potential bug when using bccwin32usa2010-12-011-0/+1
| | | | | | | | ruby with Microsoft's dll, though we already gave up of supporting bccwin32. [ruby-core:33503] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (ruby_float_step): fix Numeric#step with infinity unitnaruse2010-10-131-1/+1
| | | | | | doesn't works well. [ruby-core:32779] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (check_uint): get rid of overflow on LLP64 platforms.nobu2010-10-131-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (int_chr): raise error when the value is negative.naruse2010-10-131-1/+10
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (rb_num_to_uint): fix 32bit logic.naruse2010-10-131-2/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (rb_num_to_uint): added to check the range of arguments.naruse2010-10-131-0/+30
| | | | | | | | Mainly for negative value with NUM2UINT on 32bit environment. * string.c (rb_str_concat): use rb_num_to_uint. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e