Solved

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

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

742 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