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!

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.