Skip to content

Make Math/MathF.Sign inlineable for floating point data #57413

Closed as not planned

Description

@MichalPetryka

Description

Math/MathF.Sign for floating point data currently isn't inlined, probably due to the throw there. Since it's a simple math operation, it should probably be inlined.

Configuration

Sharplab Core CLR 5.0.721.25508 on amd64

Regression?

No idea.

Data

Sharplab

Analysis

Moving the throw there to a throw helper should probably make it inlineable.

Activity

  1. added
    tenet-performance
    on Aug 14, 2021
  2. ghost added
    untriaged
    on Aug 14, 2021
  3. added and removed
    untriaged
    on Aug 14, 2021
  4. added this to the 7.0.0 milestone on Aug 14, 2021
  5. tannergooding commented on Feb 18, 2022

    @tannergooding
    Member

    It's probably not worthwhile to make this inlineable. If perf is a consideration (and even if it isn't) then double/float.IsNegative or Math/MathF.CopySign is probably better.

    The only consideration really is that these correctly report or propagate -0 and -NaN (that is, IsNegative reports true for negative zero and negative NaN; and CopySign will do the same, copying the sign to or from such inputs).

  6. modified the milestones: 7.0.0, 8.0.0 on Aug 8, 2022
  7. dakersnar commented on Nov 29, 2022

    @dakersnar
    Contributor

    Closing this for reasons explained above.

  8. removed this from the 8.0.0 milestone on Nov 29, 2022
  9. ghost locked as resolved and limited conversation to collaborators on Dec 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Numericstenet-performance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions