Skip to content

Math.Round fails on 0.50 value #92849

@TechnVision

Description

@TechnVision

Description

As title says Math.Round fails to round 0.50 values be it decimal or double data typed, it rounds these values but returns lower values rather than it should add value 1.

For Ex. if I have to round 99.50 and put Math.Round around it then it will return 99 whereas it should return 100.

Reason: in Excel and in SQL server too its returned 100.
Screenshot 2023-09-30 190001
Screenshot 2023-09-30 190622

Reproduction Steps

Math.Round(99.50M, 0) // 100 is expected.
Math.Round(99.49M, 0) // 99 is expected and is Okey.
Math.Round(99.51M, 0) // 10 is expected and is Okey.

Expected behavior

Math.Round(99.50M, 0) // 100 is expected.

Actual behavior

Math.Round(99.50M, 0) // 99 is return

Regression?

No response

Known Workarounds

having to write logic for exact 0.50 values while rounding values

Configuration

VS22 Community version along side .Net7, on Win11

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions