From: sto.mar@... Date: 2017-02-25T20:54:53+00:00 Subject: [ruby-core:79776] [Ruby trunk Bug#13251] [DOC] Add rdoc for Integer.sqrt Issue #13251 has been updated by Marcus Stollsteimer. FYI, here my suggestion (will commit soon, need to read some HowTo's on how exactly that works, first): ``` patch diff --git a/numeric.c b/numeric.c index b34fb0a..2400a9c 100644 --- a/numeric.c +++ b/numeric.c @@ -5154,6 +5154,32 @@ DEFINE_INT_SQRT(BDIGIT, rb_bdigit_dbl, BDIGIT_DBL) VALUE rb_big_isqrt(VALUE); +/* + * Document-method: Integer::sqrt + * call-seq: + * Integer.sqrt(n) -> integer + * + * Returns the integer square root of the non-negative integer +n+, + * i.e. the largest non-negative integer less than or equal to the + * square root of +n+. + * + * Integer.sqrt(0) #=> 0 + * Integer.sqrt(1) #=> 1 + * Integer.sqrt(24) #=> 4 + * Integer.sqrt(25) #=> 5 + * Integer.sqrt(10**400) #=> 10**200 + * + * Equivalent to Math.sqrt(n).floor, except that the + * result of the latter code may differ from the true value + * due to the limited precision of floating point arithmetic. + * + * Integer.sqrt(10**46) #=> 100000000000000000000000 + * Math.sqrt(10**46).to_i #=> 99999999999999991611392 (!) + * + * If +n+ is not an Integer, it is converted to an Integer first. + * If +n+ is negative, a Math::DomainError is raised. + */ + static VALUE rb_int_s_isqrt(VALUE self, VALUE num) { ``` ---------------------------------------- Bug #13251: [DOC] Add rdoc for Integer.sqrt https://bugs.ruby-lang.org/issues/13251#change-63201 * Author: Marcus Stollsteimer * Status: Assigned * Priority: Normal * Assignee: Marcus Stollsteimer * Target version: * ruby -v: ruby 2.5.0dev (2017-02-24 trunk 57707) [x86_64-linux] * Backport: 2.2: DONTNEED, 2.3: DONTNEED, 2.4: DONTNEED ---------------------------------------- Nobu, I would offer to add documentation for Integer.sqrt, feature #13219 (r57705). I'd like to prepare a patch and eventually try to commit it myself. I'm not sure yet when to open issues for documentation and when to simply commit; I would be glad about any feedback. -- https://bugs.ruby-lang.org/ Unsubscribe: