Граф коммитов

57 Коммитов

Автор SHA1 Сообщение Дата
usa 15293df7d7 * test/bigdecimal/test_bigdecimal.rb (TestBigDecimal#test_to_f): added
for previous commit.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-31 05:52:10 +00:00
nobu d7ca01a73a bigdecimal.c: check underflow
* ext/bigdecimal/bigdecimal.c (BigDecimal_to_f): check underflow since
  strtod() sets errno to ERANGE at underflow too.  [ruby-core:47342]
  [Bug #6944]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-30 07:17:56 +00:00
naruse 2f56c64b4f Add a test: BigDecimal("0").div(BigDecimal("Infinity")).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-11 14:03:38 +00:00
naruse 0fce0545b6 * ext/bigdecimal/bigdecimal.c (Init_bigdecimal): define IDs before
they are used. [ruby-core:44900] [Bug #6406]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-07 02:03:28 +00:00
naruse 9e56e14f50 Run separate process if the test uses GC.stress.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-18 01:08:34 +00:00
nobu f5482e4c38 * ext/bigdecimal/bigdecimal.c (GetVpValueWithPrec): since methods
can be overridden, so should not make an assumption on the type
  of results.  [ruby-core:42969][Bug #6093]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-27 08:03:24 +00:00
nobu f9a4d5717c * ext/bigdecimal/bigdecimal.c (BigDecimal_s_allocate): follow
Allocation Framework.  [Bug #5775]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-21 03:35:27 +00:00
nobu 9c00c1234d * ext/bigdecimal/bigdecimal.c (Init_bigdecimal): does not follow
allocation framework right now.  [ruby-core:41710] [Bug #5773]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34070 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-18 05:34:34 +00:00
mrkn 4e8d6c105c Merge branch '5172_bigdecimal_gc_issue' into trunk
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-17 06:35:21 +00:00
mrkn 8a74797f13 * test/bigdecimal/test_bigdecimal.rb (test_version): removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-30 16:24:35 +00:00
mrkn dca0b41777 * ext/bigdecimal/lib/bigdecimal/util.rb (Rational#to_d):
zero or negative precision is error.  fixes #5098.
  [ruby-dev:44210]
* test/bigdecimal/test_bigdecimal_util.rb: add test for the above
  change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-26 15:49:47 +00:00
mrkn 079fb8d4c3 * ext/bigdecimal/lib/bigdecimal/util.rb (Float#to_d): modified for
specifying precision.  fixes #5098.  [ruby-dev:44210]
* test/bigdecimal/test_bigdecimal_util.rb: add test for the above
  change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-26 15:48:25 +00:00
mrkn 2fcb91c74c * ext/bigdecimal/lib/bigdecimal/util.rb (Integer#to_d): added
for symmetry to BigDecimal() function with an Integer.
  fixes #5098.  [ruby-dev:44210]
* test/bigdecimal/test_bigdecimal_util.rb: add test for the above
  change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-26 15:46:42 +00:00
mrkn 5ba05758fe * ext/bigdecimal/lib/bigdecimal/util.rb (BigDecimal#to_d): added
for adapting other Numeric subclasses.  [ruby-dev:44245]
* test/bigdecimal/test_bigdecimal_util.rb: test for the above change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-26 15:40:27 +00:00
mrkn a238140726 * bigdecimal/bigdecimal.c (VpDup) a new function for duplicating
a BigDecimal.

* bigdecimal/bigdecimal.c (BigDecimal_new): support generating a new
  BigDecimal from another BigDecimal using BigDecimal global function
  or constructor.  [ruby-dev:44245]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-26 15:40:23 +00:00
mrkn 99f8f14d89 * ext/bigdecimal/bigdecimal.c (rmpd_power_by_big_decimal): fix
precision treatment errors.
* test/bigdecimal/test_bigdecimal.rb: add tests for the above change.
  fix precision treatment errors.
* ext/bigdecimal/bigdecimal.c (BigDecimal_power): precision argument
  should be optional for its compatibility.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-10 14:05:07 +00:00
mrkn ebd61e5f28 * ext/bigdecimal/bigdecimal.c (BigDecimal_power): support non-integral
exponent.  fixes #3271
* ext/bigdecimal/bigdecimal.c (rmpd_power_by_big_decimal): ditto.
* ext/bigdecimal/bigdecimal.c (BigDecimal_power_op): add a function to
  only use for "**" operator.
* test/bigdecimal/test_bigdecimal.rb: add a bunch of tests for the
  above changes.
* ext/bigdecimal/bigdecimal.c (is_integer): add an utility function.
* ext/bigdecimal/bigdecimal.c (is_negative): ditto.
* ext/bigdecimal/bigdecimal.c (is_positive): ditto.
* ext/bigdecimal/bigdecimal.c (is_zero): ditto.
* ext/bigdecimal/bigdecimal.c (is_one): ditto.
* ext/bigdecimal/bigdecimal.c (is_even): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-10 03:19:49 +00:00
mrkn bb6384761e * ext/bigdecimal/bigdecimal.c (BigMath_s_log): move BigMath.log from
bigdecimal/math.rb.
* ext/bigdecimal/lib/bigdecimal/math.rb: ditto.
* test/bigdecimal/test_bigdecimal.rb: move test for BigMath.log from
  test/bigdecimal/test_bigmath.rb.
* test/bigdecimal/test_bigmath.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32258 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27 16:26:09 +00:00
mrkn f107d1e706 * ext/bigdecimal/bigdecimal.c (BigMath_s_exp): move BigMath.exp from
bigdecimal/math.rb.
* ext/bigdecimal/lib/bigdecimal/math.rb: ditto.
* test/bigdecimal/test_bigdecimal.rb: move test for BigMath.exp from
  test/bigdecimal/test_bigmath.rb.
* test/bigdecimal/test_bigmath.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 17:38:14 +00:00
mrkn 3bd8b390de * ext/bigdecimal/bigdecimal.c (BigDecimalCmp): use GetVpValueWithPrec
for Float and Rational arguments.
* test/bigdecimal/test_bigdecimal.rb (test_new, test_cmp, test_power):
  add and modify tests for the above change.
* ext/bigdecimal/bigdecimal.c (BigDecimalCmp): modify coding style to
  match ruby's standard.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32052 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-13 09:51:48 +00:00
mrkn 678b6820f7 * ext/bigdecimal/bigdecimal.c (GetVpValueWithPrec): support instantiation from
a Float through Rational.
* ext/bigdecimal/bigdecimal.c (BigDecimal_new): ditto.
* test/bigdecimal/test_bigdecimal.rb (test_global_new_float): add a test for
  the above changes.
* test/bigdecimal/test_bigdecimal.rb (test_new_with_float): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-31 15:33:42 +00:00
mrkn d7058e10dc * ext/bigdecimal/bigdecimal.c (BigDecimal_coerce): support coerce with a
Rational.  The precision used for instantiate a BigDecimal from the
  given Rational is obtained from the receiver BigDecimal.
* test/bigdecimal/test_bigdecimal.rb (test_coerce): add a test for the
  above change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-31 15:09:38 +00:00
mrkn 100931ac2c * ext/bigdecimal/bigdecimal.c (GetVpValueWithPrec): replace the algorithm for
coercing from a Rational to stop requiring "bigecimal/util.rb".
  [ruby-core:34318]
* ext/bigdecimal/bigdecimal.c (GetVpValue): refactoring.
* ext/bigdecimal/bigdecimal.c (BigDecimal_new): support instantiation from a
  Rational.
* test/bigdecimal/test_bigdecimal.rb (test_global_new_with_rationao): add a
  test for the above change.
* test/bigdecimal/test_bigdecimal.rb (test_new_with_rationao): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-31 14:43:39 +00:00
mrkn b54141bb1b * ext/bigdecimal/bigdecimal.c (BigDecimal_new): support instantiation a
BigDecimal object from an Integer.
* test/bigdecimal/test_bigdecimal.rb (test_new_with_integer):
  add for testing the above change.
* ext/bigdecimal/bigdecimal.c (BigDecimal_global_new): replace its body
  with a BigDecimal_new call.
* test/bigdecimal/test_bigdecimal.rb (test_global_new_with_integer):
  add for testing the above change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-31 13:45:31 +00:00
mrkn ecfc868bdb * ext/bigdecimal/bigdecimal.c (BigDecimal_save_limit):
return the result of a block.
* test/bigdecimal/test_bigdecimal.rb (test_save_limit):
  add a test for the above change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-09-29 08:55:11 +00:00
mrkn fed832d7f2 * ext/bigdecimal/bigdecimal.c (BigDecimal_save_rounding_mode):
return the result of a block.
* test/bigdecimal/test_bigdecimal.rb (test_save_rounding_mode):
  add a test for the above change.
* test/bigdecimal/test_bigdecimal.rb (test_save_exception_mode):
  add a test for the return value of BigDecimal.save_exception_mode.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-09-29 04:32:20 +00:00
mrkn 971a57004e * ext/bigdecimal/bigdecimal.c (check_rounding_mode, BigDecimal_mode):
raise ArgumentError instead of TypeError passing invalid modes.
* test/bigdecimal/test_bigdecimal.rb (test_mode, test_round):
  change against the above modifications.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-09-19 17:38:18 +00:00
mrkn fb7fe14575 * ext/bigdecimal/bigdecimal.c (check_rounding_mode): added for
converting symbol to rounding mode number.
* ext/bigdecimal/bigdecimal.c (BigDecimal_mode, BigDecimal_round):
  support to specify rounding mode by symbol.
* test/bigdecimal/test_bigdecimal.rb (test_mode, test_round):
  add tests for avobe changes.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-09-18 21:06:08 +00:00
mrkn 3cbda570c2 * ext/bigdecimal/bigdecimal.c: fix rounding algorithms for half-down
and half-even.  This change is based on the patch created by Matthew
  Willson, the reporter of this bug.  [Bug #3803] [ruby-core:32136]
* test/bigdecimal/test_bigdecimal.rb: add tests for above changes.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-09-18 20:19:38 +00:00
mrkn a2bf9203e8 * ext/bigdecimal/bigdecimal.c (BigDecimal_save_exception_mode,
BigDecimal_save_rounding_mode, BigDecimal_save_limit): added.
* test/bigdecimal/test_bigdecimal.rb: added tests for the above
  features.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-28 08:52:14 +00:00
mrkn 3dc6edf793 * ext/bigdecimal/bigdecimal.c (Init_bigdecimal, rmpd_set_thread_local_exception_mode, VpGetException, VpSetException): thread-local exception mode.
* ext/bigdecimal/bigdecimal.c (Init_bigdecimal, rmpd_set_thread_local_precision_limit, VpGetPrecLimit, VpSetPrecLimit): thread-local precision limit.
* ext/bigdecimal/bigdecimal.c (Init_bigdecimal, rmpd_set_thread_local_rounding_mode, VpGetRoundMode, VpSetRoundMode, VpException, VpInternalRound): thread-local rounding mode.
* ext/bigdecimal/bigdecimal.c (BigDecimal_mode, BigDecimal_round, VpIsRoundMode, VpGetRoundMode, VpSetRoundMode, VpActiveRound, VpMidRound, VpLeftRound), ext/bigdecimal/bigdecimal.h: use unsigned short for rounding mode.
* test/bigdecimal/test_bigdecimal.rb (test_mode): add test for setting rounding mode.
* test/bigdecimal/test_bigdecimal.rb (test_thread_local_mode): add test for setting mode thread-locally.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-26 00:14:18 +00:00
mrkn af8cae1e7f * ext/bigdecimal/bigdecimal.c (BigDecimal_to_f): to_f must underflow when the exponent is less than DBL_MIN_10_EXP - BASE_FIG.
* test/bigdecimal/test_bigdecimal.rb (test_to_f): added test for the above changes.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-23 16:22:04 +00:00
mrkn d86da0fcf1 * ext/bigdecimal/extconf.rb, ext/bigdecimal/bigdecimal.h (labs, llabs): support environments missing labs and llabs.
* ext/bigdecimal/bigdecimal.h (vabs): added.
* ext/bigdecimal/extconf.rb, ext/bigdecimal/bigdecimal.h, ext/bigdecimal/bigdecimal.c, test/bigdecimal/test_bigdecimal.rb (TestBigDecimal#test_new): replace U_LONG, S_LONG, S_INT, and U_INT with appropreate standard or ruby-provided types.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-14 15:22:43 +00:00
mrkn 1c3e07f0d6 * ext/bigdecimal/bigdecimal.c (Init_bigdecimal): add two new constants BigDecimal::INFINITY and BigDecimal::NAN.
* ext/bigdecimal/lib/bigdecimal/math.rb (BigMath.exp): modify the behaviors for infinity arguments as same as Math.exp.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-03 07:47:00 +00:00
mrkn 74365313f7 * ext/bigdecimal/lib/bigdecimal/math.rb (atan), test/bigdecimal/test_bigmath.rb (test_atan): explicitly specify the precision for calculating a reciprocal number of an argument. [Bug #3267]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-11 05:11:59 +00:00
nobu 64dee0063b * test/bigdecimal/test_bigdecimal.rb (TestBigDecimal#test_gc):
reduced heavy test.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-09 16:00:37 +00:00
nobu c4546f190a * test/bigdecimal/test_bigdecimal.rb (TestBigDecimal#test_gc):
fixed test subject.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-09 14:38:56 +00:00
nobu 66abf4ad68 * ext/bigdecimal/bigdecimal.c (VpAlloc): ensure buf does not get
collected.  based on a patch masaya tarui at [ruby-dev:41213].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-08 02:07:43 +00:00
naruse 54476a6024 * ext/bigdecimal/bigdecimal.c (VpCtoV): fix to check overflow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-06 19:28:12 +00:00
nobu 9803f4f55a * test/bigdecimal/testbase.rb (teardown): should reset all modes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-26 01:55:51 +00:00
naruse e41936441b Surpress warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-06 03:01:52 +00:00
mame 05d80e2fc6 * ext/bigdecimal/bigdecimal.c (VpCtoV): BigDecimal("0E200000000000")
was Infinity, not 0.

* test/bigdecimal/test_bigdecimal.rb: add a test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-26 12:52:49 +00:00
marcandre c07e7d167d * ext/bigdecimal/bigdecimal.c (BigDecimalCmp): Fix comparisons [ruby-core:26646]
* test/bigdecimal/test_bigdecimal.rb (class): Fix and improve tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-14 00:17:07 +00:00
nobu 39ea1c8c7c * ext/bigdecimal/lib/bigdecimal/math.rb (atan): atan(Infinity) is
PI/2.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-23 17:21:26 +00:00
nobu d9bfa822ea * ext/bigdecimal/bigdecimal.c (GetVpValue): support conversion from
Rational.  [ruby-core:25697]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-21 19:47:39 +00:00
nobu cd4f59bc5e * ext/bigdecimal/lib/bigdecimal/math.rb (sin, cos, atan, exp, log):
improved precision and performance.  based on a patch from Makoto
  Yamashita in [ruby-core:25600] and [ruby-core:25602].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-20 15:07:38 +00:00
kazu 3d923f01bf * test/bigdecimal/test_bigdecimal.rb (TestBigDecimal#test_hash):
shut up warning.  see [ruby-dev:37437]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-17 02:40:53 +00:00
matz 4d3f3af836 * ext/bigdecimal/bigdecimal.c (BigDecimal_DoDivmod): bigdecimal
division (including modulo) should raise ZeroDivisionError as
  integer division. [incompatible]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-27 17:20:08 +00:00
matz 0434b0f098 * ext/bigdecimal/bigdecimal.c (VpException): bigdecimal zero
division should raise FloatDomainError if mode
  VP_EXCEPTION_ZERODIVIDE is set.  [ruby-dev:37204]

* ext/bigdecimal/bigdecimal.c (BigDecimal_mode): should handle
  VP_EXCEPTION_ZERODIVIDE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-26 14:04:58 +00:00
matz a426373520 * ext/bigdecimal/bigdecimal.c (VpAlloc): avoid ALLOCA_N() to avoid
segmentation fault caused by (insanely) long decimal values.
  [ruby-dev:37189] fix #794

* ext/bigdecimal/bigdecimal.c (BigDecimal_dump, BigDecimal_to_i,
  BigDecimal_to_f, BigDecimal_to_s, BigDecimal_split,
  BigDecimal_inspect): ditto.

* ext/bigdecimal/bigdecimal.c (VpToString): small performance
  improvement.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-25 18:02:42 +00:00