Rounding decimal when the last significant digit is 5

Richard77

Why is ROUND(2.05, 1) producing 2.0? Isn't supposed to produce 2.1?

Thanks for helping

EDIT

SELECT 
p.AdjustPercent,
CAST(CAST(ROUND(p.AdjustPercent, 1) AS DECIMAL(10, 1)) AS VARCHAR(50)) + '%',
....

I've got things like

2.38      2.4%
2.05      2.0%
user6638270

I think I know what your problem is. Is your type a float? Bear in mind that 2.05 float can well be 2.049999998. Hence it rounds down.

Try the following:

DECLARE @f float = 2.05
DECLARE @d decimal(10,2) = 2.05
DECLARE @n numeric(10,4) = 2.05

SELECT ROUND(2.05, 1)
SELECT ROUND(@f, 1)
SELECT ROUND(@d, 1)
SELECT ROUND(@n, 1)

Results

2.10
2
2.10
2.1000

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

rounding through rule of significant digit

From Dev

Why is my decimal rounding to 1 significant figure?

From Dev

Position of first significant digit after the decimal point

From Dev

How to stop Mathematica rounding the last digit of a number when converting it to string using ToString?

From Dev

decimal js rounding 3digit numbers [probably a bug?]

From Dev

Rounding to n significant digits

From Dev

How to add a decimal to a 5 digit number

From Dev

Rounding Decimal

From Dev

Rounding When Last Number is Zero - Applescript

From Dev

R: Rounding error when extracting ending digit from a number

From Dev

Rounding to Significant Figures - Missing Zeros

From Dev

Rounding to Significant Figures - Missing Zeros

From Dev

How can I remove last digit from decimal number in PHP

From Dev

Javascript - How to get the last digit after decimal number?

From Dev

How can I remove last digit from decimal number in PHP

From Dev

Rounding values inside nested list to 2nd digit after decimal

From Dev

Get most significant digit in python

From Dev

Show decimal of a double only when needed (rounding issue)

From Dev

Why does Excel round the least significant digit when I paste in a large number?

From Dev

How to do SQL Server rounding digit by digit?

From Dev

Moving decimal without rounding

From Dev

Decimal rounding and printer selection

From Dev

Mask a decimal without rounding

From Dev

.Net decimal rounding oddities

From Dev

Rounding to two decimal places

From Dev

Decimal not rounding properly

From Dev

Decimal module: rounding

From Dev

Decimal rounding and printer selection

From Dev

Decimal Rounding in C#

Related Related

HotTag

Archive