Solved

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

Posted on 2008-06-18
3
301 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get Actionable Data from Your Monitoring Solution

Your communication platform is only as good as the relevance of the information you send. Ensure your alerts get to the right people every time with actionable responses. Create escalation rules that ensure everyone follows the process and nothing is left to chance.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 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