Project

General

Profile

Actions

Bug #12952

closed

Incompatibility of a method signature between `Float#round` and `BigDecimal#round`

Added by yui-knk (Kaneko Yuichiro) about 8 years ago. Updated about 8 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.4.0preview3 (2016-11-07 trunk 56661) [x86_64-darwin14]
[ruby-core:78191]

Description

We can not call BigDecimal("0.5").round(half: :up).
This prevents us from duck typing Float objects and BigDecimal objects.

irb(main):001:0> require "bigdecimal"
=> true
irb(main):002:0> 0.5.round(half: :up)
=> 1
irb(main):003:0> BigDecimal("0.5").round(half: :up)
TypeError: no implicit conversion of Hash into Integer
	from (irb):3:in `round'
	from (irb):3
	from /Users/kaneko/.rbenv/versions/2.4.0-preview3/bin/irb:11:in `<main>'
irb(main):004:0> BigDecimal.ver
=> "1.1.0"

Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #12953: (Float, Integer, Rational)#round(half: :down)ClosedActions

Updated by mrkn (Kenta Murata) about 8 years ago

  • Status changed from Open to Assigned
  • Assignee set to mrkn (Kenta Murata)
Actions #2

Updated by mrkn (Kenta Murata) about 8 years ago

  • Related to Feature #12953: (Float, Integer, Rational)#round(half: :down) added

Updated by mrkn (Kenta Murata) about 8 years ago

I've fixed this in bigdecimal version 1.3.0.pre, which has already been imported in trunk.

Updated by mrkn (Kenta Murata) about 8 years ago

  • Status changed from Assigned to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0