0

Hello everybody!

There's something I can't figure out myself.
I'd like to use an hscrollbar for setting a float value. The float would be from 0 to 1, like 0.02, etc.
So I'd use the integer value of the hscrollbar, and divide it by 100. But if try it, I get 1 for 100 and 0 for any other number, like 83/100=0. But I'd like to get 0.83, you see.

What is the correct conversion method for this?

Thanks in advance!

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by konczuras
1

Convert your integer to float before doing the division.
e.g.
int nIn = 50;
float fOut;
fOut = ((float)nIn)/100;

0

Thank you very much for the quick answer, that works just as I wanted!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.