Solved

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

Posted on 2008-06-18
290 Views
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;

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);

}
``````
0
• 2

Author Comment

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

margajet24 earned 500 total points
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

thanks alot, excelent ;)
0

## Featured Post

### Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…