Project

General

Profile

Actions

Bug #7044

closed

BigDecimal#power randomly raises coercion errors

Added by twooster (Tony Wooster) about 12 years ago. Updated almost 12 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
Backport:
[ruby-core:47632]

Description

When running the following code:

require 'bigdecimal'

10000.times { BigDecimal.new('1001.10')**0.75; putc '.' }

The call to ** will sometimes (not always) raise the following trace:

..............................................TypeError: #<Class:0x0000001cd78f40> can't be coerced into BigDecimal
	from (irb):4:in `**'
	from (irb):4:in `block in irb_binding'
	from (irb):3:in `times'
	from (irb):3
	from /home/tony/.rbenv/versions/1.9.3-p194/bin/irb:12:in `<main>'

(The '.'s being the debug print of the putc.) I understand the documentation says only integer powers are supported for BigDecimal, however there is code support for floats and rationals, and it should fail or work reliably either way.

Actions

Also available in: Atom PDF

Like0
Like0Like0