Skip to content

Commit

Permalink
Extend docs for round(0)
Browse files Browse the repository at this point in the history
Since #170, `big_decimal.round(0)` returns an Integer. This was surprising to me, as the documentation does not specify the behavior for this case. (It could even be seen as misleading / wrong.)
  • Loading branch information
franzliedke authored Jun 20, 2024
1 parent ae3915b commit 6c2bb36
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ext/bigdecimal/bigdecimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2459,14 +2459,15 @@ BigDecimal_fix(VALUE self)
* round(n, mode)
*
* Round to the nearest integer (by default), returning the result as a
* BigDecimal if n is specified, or as an Integer if it isn't.
* BigDecimal if n is specified and positive, or as an Integer if it isn't.
*
* BigDecimal('3.14159').round #=> 3
* BigDecimal('8.7').round #=> 9
* BigDecimal('-9.9').round #=> -10
*
* BigDecimal('3.14159').round(2).class.name #=> "BigDecimal"
* BigDecimal('3.14159').round.class.name #=> "Integer"
* BigDecimal('3.14159').round(0).class.name #=> "Integer"
*
* If n is specified and positive, the fractional part of the result has no
* more than that many digits.
Expand Down

0 comments on commit 6c2bb36

Please sign in to comment.