Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rounding a decimal number up to the nearest even tenth... 1

Status
Not open for further replies.

alexjones

Programmer
Jul 27, 2001
132
0
0
US
Examples: 24.31 would round up to 24.4
24.48 would round up to 24.6.

Anybody got a slick way of doing this?
 
Multiply by 10. Use the ceiling function. Divide by 10.

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Thanks for the quick response. The kicker here is the requirement that the number be rounded up to the nearest EVEN tenth.

So 24.48 should round up to 24.6 and ceiling(24.48 * 10) / 10 yields 24.5.

alex
 
Sorry. I missed that part. Use 5 instead of 10.

Select ceiling(24.48 * ]!]5[/!]) / [!]5[/!]

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Select ceiling(24.48 * [!]5[/!]) / [!]5 [/!]

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top