Solved

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

Posted on 2008-06-18
3
290 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
Comment Utility
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
Comment Utility
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
Comment Utility
thanks alot, excelent ;)
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…

771 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

10 Experts available now in Live!

Get 1:1 Help Now