I always get 0 for percentage when I do this:
int trackBarValue = trackBar.Value;
float percentage = trackBarValue / 100;
What’s wrong with my code?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The problem is you’re doing an integer division, which is truncated. Try this:
This will do a floating point division, and given you the result you want.