Solved

how to use decimal deviding in c#, for counting prosent used of transactions in my case....

Posted on 2008-06-18
3
292 Views
Last Modified: 2013-12-16
i am creating a function to count prosent used transaction in my program, i am getting total prosent to be example: 0,673 , but i want it to be int,   6 %  prosent.....

 
int MaxTrans;

                int UsedTrans;

                decimal Totalt;

                LicenseInfoDictionary.TryGetValue("MaxTrans", out MaxTrans);

                LicenseInfoDictionary.TryGetValue("UsedTrans", out UsedTrans);

                Totalt = Decimal.Divide(UsedTrans * 100 , MaxTrans);

               // Totalt =  (UsedTrans * 100) ,MaxTrans;

                if (Totalt <= 6)

                {

                    MainForm.RunningForm.FadeIn(GetValue("usedTransactions") + " " + UsedTrans + " " + GetValue("usedOf") + " " + MaxTrans,

                        GetValue("tranLeft") + " " + Totalt + " " + GetValue("tranLeft1"), 16000);

                }

Open in new window

0
Comment
Question by:Adnan
  • 2
3 Comments
 

Author Comment

by:Adnan
ID: 21811336
can somone help me with this issue, i want to int and not a double result....

from 0,673 i want it to be like 6%...
0
 
LVL 10

Accepted Solution

by:
margajet24 earned 500 total points
ID: 21811459
Totalt = Decimal.Divide(UsedTrans * 100 , MaxTrans) // is multiplying by 100 on purpose?

if yes,
Totalt = Decimal.Divide(UsedTrans * 100 , MaxTrans) * 10; // to get 6 from 0.673

if no,
Totalt = Decimal.Divide(UsedTrans, MaxTrans) * 100; // ( UsedTrans / MaxTrans ) * 100 [percentage of used trans]

int percent = Convert.ToInt32(Totalt); // to remove decimal points..
0
 

Author Closing Comment

by:Adnan
ID: 31468266
thanks alot, excelent ;)
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now