Solved

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

Posted on 2008-06-18
3
295 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

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.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

773 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