Feature #12245
optional parameter ndigits to Integer#floor, Integer#ceil, Float#floor, Float#ceil
Description
Related to [Feature #12244].
I think that Integer#floor
, Integer#ceil
, Float#floor
, and Float#ceil
should have optional parameter ndigits
, as well as round
methods.
https://github.com/ruby/ruby/compare/trunk...nobu:feature/Integer%23floor-ndigits
https://github.com/ruby/ruby/compare/trunk...nobu:feature/Integer%23ceil-ndigits
https://github.com/ruby/ruby/compare/trunk...nobu:feature/Float%23floor-ndigits
https://github.com/ruby/ruby/compare/trunk...nobu:feature/Float%23ceil-ndigits
Associated revisions
numeric.c: int_ceil
- numeric.c (int_ceil): add an optional parameter, digits, as well as Integer#round. [Feature #12245]
numeric.c: int_ceil
- numeric.c (int_ceil): add an optional parameter, digits, as well as Integer#round. [Feature #12245]
numeric.c: int_ceil
- numeric.c (int_ceil): add an optional parameter, digits, as well as Integer#round. [Feature #12245]
numeric.c: int_ceil
- numeric.c (int_ceil): add an optional parameter, digits, as well as Integer#round. [Feature #12245]
numeric.c: flo_floor
- numeric.c (flo_floor): add an optional parameter, digits, as well as Integer#floor. [Feature #12245]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
numeric.c: flo_floor
- numeric.c (flo_floor): add an optional parameter, digits, as well as Integer#floor. [Feature #12245]
numeric.c: flo_floor
- numeric.c (flo_floor): add an optional parameter, digits, as well as Integer#floor. [Feature #12245]
numeric.c: flo_floor
- numeric.c (flo_floor): add an optional parameter, digits, as well as Integer#floor. [Feature #12245]
numeric.c: flo_floor
- numeric.c (flo_floor): add an optional parameter, digits, as well as Integer#floor. [Feature #12245]
numeric.c: flo_ceil
- numeric.c (flo_ceil): add an optional parameter, digits, as well as Float#round. [Feature #12245]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
numeric.c: flo_ceil
- numeric.c (flo_ceil): add an optional parameter, digits, as well as Float#round. [Feature #12245]
numeric.c: flo_ceil
- numeric.c (flo_ceil): add an optional parameter, digits, as well as Float#round. [Feature #12245]
numeric.c: flo_ceil
- numeric.c (flo_ceil): add an optional parameter, digits, as well as Float#round. [Feature #12245]
numeric.c: flo_ceil
- numeric.c (flo_ceil): add an optional parameter, digits, as well as Float#round. [Feature #12245]
NEWS: mention [Feature #12245]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
NEWS: mention [Feature #12245]
NEWS: mention [Feature #12245]
NEWS: mention [Feature #12245]
NEWS: mention [Feature #12245]
numeric.c: update doc [ci skip]
- numeric.c (int_to_i): [DOC] floor and ceil are no longer synonyms. [Feature #12245]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
numeric.c: update doc [ci skip]
- numeric.c (int_to_i): [DOC] floor and ceil are no longer synonyms. [Feature #12245]
numeric.c: update doc [ci skip]
- numeric.c (int_to_i): [DOC] floor and ceil are no longer synonyms. [Feature #12245]
numeric.c: update doc [ci skip]
- numeric.c (int_to_i): [DOC] floor and ceil are no longer synonyms. [Feature #12245]
numeric.c: update doc [ci skip]
- numeric.c (int_to_i): [DOC] floor and ceil are no longer synonyms. [Feature #12245]
test_float.rb: assertions for negative floats
- test/ruby/test_float.rb: add assertions for round,floor,ceil on negative floats. [Feature #12245]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
test_float.rb: assertions for negative floats
- test/ruby/test_float.rb: add assertions for round,floor,ceil on negative floats. [Feature #12245]
test_float.rb: assertions for negative floats
- test/ruby/test_float.rb: add assertions for round,floor,ceil on negative floats. [Feature #12245]
test_float.rb: assertions for negative floats
- test/ruby/test_float.rb: add assertions for round,floor,ceil on negative floats. [Feature #12245]
test_float.rb: assertions for negative floats
- test/ruby/test_float.rb: add assertions for round,floor,ceil on negative floats. [Feature #12245]
numeric.c: int_truncate
- numeric.c (int_truncate): add an optional parameter, digits, as well as Integer#round. [Feature #12245]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
numeric.c: int_truncate
- numeric.c (int_truncate): add an optional parameter, digits, as well as Integer#round. [Feature #12245]
numeric.c: int_truncate
- numeric.c (int_truncate): add an optional parameter, digits, as well as Integer#round. [Feature #12245]
numeric.c: int_truncate
- numeric.c (int_truncate): add an optional parameter, digits, as well as Integer#round. [Feature #12245]
numeric.c: int_truncate
- numeric.c (int_truncate): add an optional parameter, digits, as well as Integer#round. [Feature #12245]
numeric.c: flo_truncate
- numeric.c (flo_truncate): add an optional parameter, digits, as well as Float#round. [Feature #12245]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
numeric.c: flo_truncate
- numeric.c (flo_truncate): add an optional parameter, digits, as well as Float#round. [Feature #12245]
numeric.c: flo_truncate
- numeric.c (flo_truncate): add an optional parameter, digits, as well as Float#round. [Feature #12245]
numeric.c: flo_truncate
- numeric.c (flo_truncate): add an optional parameter, digits, as well as Float#round. [Feature #12245]
numeric.c: flo_truncate
- numeric.c (flo_truncate): add an optional parameter, digits, as well as Float#round. [Feature #12245]
numeric.c: numeric ndigits
- numeric.c (num_floor, num_ceil, num_truncate): add an optional parameter, digits, as well as Numeric#round. [Feature #12245]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
numeric.c: numeric ndigits
- numeric.c (num_floor, num_ceil, num_truncate): add an optional parameter, digits, as well as Numeric#round. [Feature #12245]
numeric.c: numeric ndigits
- numeric.c (num_floor, num_ceil, num_truncate): add an optional parameter, digits, as well as Numeric#round. [Feature #12245]
numeric.c: numeric ndigits
- numeric.c (num_floor, num_ceil, num_truncate): add an optional parameter, digits, as well as Numeric#round. [Feature #12245]
numeric.c: numeric ndigits
- numeric.c (num_floor, num_ceil, num_truncate): add an optional parameter, digits, as well as Numeric#round. [Feature #12245]
History
Updated by shevegen (Robert A. Heiler) over 3 years ago
I think that would make sense.
I usually add an extra method call afterwards to round it manually (or, if not .round then to use it as a string and sprintf, % or .ljust / .rjust output it).
I should also note that newcomers often ask on IRC how to round / display something properly, so anything that may be of help here, is good I think. (It will be typical question such as how to display a float like 3.0 as 3.000, if only for properly padded output with other float values that will have 3 slots past the . like 2.983 and so on)
Updated by nobu (Nobuyoshi Nakada) over 3 years ago
- Status changed from Open to Closed
Applied in changeset r54562.
numeric.c: int_ceil
- numeric.c (int_ceil): add an optional parameter, digits, as well as Integer#round. [Feature #12245]
numeric.c: int_ceil
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e