The Question:
I am using Visual C# Express 2010. I am trying to divide three integers, however, the result is always 0.
My Code:
//earlier in the code:
int totalKeywords = 3;
//the problem code:
decimal onePercent = 100 / totalKeywords / 100; //100% divided by the number of keywords divided by 100 to make one percent
MessageBox.Show(onePercent);
//result: 0
//what I want: 0.33 or more acurate
What I've tried:
- I've changed the value of totalKeywords
- I've tried onePercent as a double, int, float, ect.
Guesses:
- It could be that the built-in math doesn't work for some reason (WHY??)
- It could be that decimal / int / float, etc. don't hold decimals (I don't think so)
My Efforts:
- Stack Overflow