Skip to content

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

Closed
robin850 wants to merge 1 commit into
rubinius:masterfrom
robin850:float-signbit
Closed

Rename Float#negative? to Float#signbit?#3469
robin850 wants to merge 1 commit into
rubinius:masterfrom
robin850:float-signbit

Conversation

@robin850

Copy link
Copy Markdown
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
Copy Markdown

Rebased into 533da7e, thanks!

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

brixen commented Jul 18, 2015

Copy link
Copy Markdown
Member

@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.

3 participants