?
Solved

Trying to round a quotient down

Posted on 2008-11-12
2
Medium Priority
?
829 Views
Last Modified: 2012-05-05
I am dividing two decimals. I need the quotient to always round down.Also, the resulting quotient should  be a whole number integer. Currently I can make the quotient round to the nearest whole number (int numoftwenties = (int)Math.Round((decimal)change /20.00m);, but I need it round down. I am trying to calculate the number of twenty dollar bills that would be given back as change to a customer.

For example if a customer was to receive 95.00 dollars in change back. They would receive 4  (not 5)twenty dollar bills back.
0
Comment
Question by:jazzcatone
2 Comments
 
LVL 23

Accepted Solution

by:
Jens Fiederer earned 500 total points
ID: 22943005
You should to use Math.Truncate for this
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 22943074
You could also just use INTEGER DIVISION like this:

    int numoftwenties = (int)change / (int)20;
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question