• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 388
  • Last Modified:

Rounding Question 2

Hello again

DEClare @test decimal(10, 4)
set @test = 333.3334
select ceiling(@test * 100) / 100

indeed result is good with 333.34

but if i put 333.3333    the result is still 333.34    thats not good...

maybe im doing this wrong but i dont understand why it puts a 4 if there is not 4 in 333.3333
0
PhilippeRenaud
Asked:
PhilippeRenaud
  • 4
  • 2
  • 2
2 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
because CEILING is rouding up.

possibly you are wording your question incorrectly....
you might not want to do "rounding", actually.

please clarify with a couple of data values => expected result  what you are really trying to achieve?
0
 
PhilippeRenaudAuthor Commented:
Alright..


if I have 333.3333

in real life we dont have 0.0033 cents" its doest exist

so if in table I have 333.3333   I want to show 333.33  $

if I have 333.3334    I want to show 333.34

if 555.5555       555.55 $

if 888.8889      888.89 $
0
 
HainKurtSr. System AnalystCommented:
"if in table I have 333.3333   I want to show 333.33  $
if I have 333.3334    I want to show 333.34"

whats the logic behind this????
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
PhilippeRenaudAuthor Commented:
dont talk about logic just tell me if its possible

the application is too far ahead to modify.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
your amounts you show are not "real-life", aka not all the amounts possible...

what about 33.3389 ? 33.1234 ? 33.4321  ? 33.9876  etc ...
0
 
PhilippeRenaudAuthor Commented:
ok let me think.
0
 
HainKurtSr. System AnalystCommented:
maybe you need this

ceiling(FLOOR(@test*1000)/10)/100
0
 
PhilippeRenaudAuthor Commented:
I understansd that the logic is somewhat odd and I need to fix this instead but its not my code.
I will split points with you all but the problem is elsewhere.


thanks,
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now