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

Rename Float#negative? to Float#signbit? #3469

Closed
wants to merge 1 commit into from
Closed

Rename Float#negative? to Float#signbit? #3469

wants to merge 1 commit into from

Conversation

robin850
Copy link
Contributor

Hello,

Ruby 2.3 ships with a new Numeric#negative? method. Rubinius implements this method since b92c84f, for internal usage though ; it delegates to the signbit C++ function.

However, signbit's behavior can't match MRI Float#negative?'s one since the former operates on the sign while the latter operates on the value (see here).

This makes a test to fail on the Rails test suite (the same example is present in the signbit's documentation and -0.0 is considered negative this time).

Moreover, if people rely on feature detection rather than version checking, they may wrongly assume that the current running Ruby is 2.3+ checking if a float respond to #negative?.

Have a nice day!

Ruby 2.3 ships with a new `Numeric#negative?` method. Rubinius implements
this method since b92c84f, for internal usage though ; it delegates to
the signbit C++ function.

However, `signbit`'s behavior can't match MRI `Float#negative?`'s one
since the former operates on the sign while the latter operates on the
value (see http://git.io/vm1fg).
@yorickpeterse
Copy link
Contributor

Rebased into 533da7e, thanks!

@robin850 robin850 deleted the float-signbit branch July 18, 2015 12:47
@brixen
Copy link
Member

brixen commented Jul 18, 2015

@robin850 if people are relying on checking a method for version, please direct them to https://github.com/brixen/redcard. We won't be fixing issues where people wrongly use methods or classes to infer the Ruby version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants