Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced RDoc for Float #5144

Merged
merged 2 commits into from Nov 19, 2021
Merged

Enhanced RDoc for Float #5144

merged 2 commits into from Nov 19, 2021

Conversation

BurdetteLamar
Copy link
Member

Treats:

  • #to_s
  • #coerce
  • #+
  • #-
  • #*
  • #/

@BurdetteLamar BurdetteLamar added the Documentation Improvements to documentation. label Nov 18, 2021
Copy link
Contributor

@jeremyevans jeremyevans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good. I think for the basic mathematical operators, we should reduce the number of examples, see inline comments.

numeric.c Outdated
@@ -991,7 +1004,6 @@ flo_to_s(VALUE flt)
}
else if (isnan(value))
return rb_usascii_str_new2("NaN");

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, please avoid making non-documentation changes during documentation updates.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good. I think for the basic mathematical operators, we should reduce the number of examples, see inline comments.

Don't agree on this one. I think it's worth reminding that the result may not be a Float, and in particular that it may be Infinity, -Infinity, or NaN. Maybe the call-seqs should be changed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, please avoid making non-documentation changes during documentation updates.

A mistake; will correct. Thanks for noticing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't object to the example showing the return of Complex result. I don't think it makes sense to include Infinite/NaN example results for every method. Those should be considered similar to exceptions, and we don't provide examples for exceptions per the documentation guide.

numeric.c Outdated
* f + 1.0 # => 4.140000000000001
* f + Rational(1, 1) # => 4.140000000000001
* f + Complex(1, 0) # => (4.140000000000001+0i)
* f + Float::MAX # => 1.7976931348623157e+308
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these last 4 examples can be dropped.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

numeric.c Outdated
* f - 1.0 # => 2.14
* f - Rational(1, 1) # => 2.14
* f - Complex(1, 0) # => (2.14+0i)
* f - (Float::MAX * 2) # => -Infinity
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, these last three examples can be dropped.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

numeric.c Outdated
* f * 2.0 # => 6.28
* f * Rational(1, 2) # => 1.57
* f * Complex(2, 0) # => (6.28+0.0i)
* f * Float::MAX # => Infinity
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for these last three examples.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

numeric.c Outdated
* f / 2.0 # => 1.57
* f / Rational(2, 1) # => 1.57
* f / Complex(2, 0) # => (1.57+0.0i)
* f / 0 # => Infinity
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And these last three examples.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@BurdetteLamar
Copy link
Member Author

@jeremyevans, ready for review/approval.

Copy link
Contributor

@jeremyevans jeremyevans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@BurdetteLamar BurdetteLamar merged commit e0c3874 into ruby:master Nov 19, 2021
@BurdetteLamar
Copy link
Member Author

@jeremyevans, back in the day I wrote thousands and thousands of lines of i860 assembler code for vector-concurrent double-precision numerical functions. So NaN etc. are old and dear friends. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Improvements to documentation.
2 participants