1. ## Variable Type issue

Hi

Is there a function similar to "SetDlgItemInt()" which is able to work with non integers (decimals)?

Apparently SetDlgItemInt() is not required for float or double types, what do you recommend?

Thank you

2. Convert data to string, use SetDlgItemText. To convert data to a string, you can use sprintf.

3. You could use SetDlgItemText() - then just create the text that you want to see.

gg

4. Ok That was actually my solution before... I can stick to that

But In that case I have problems with determination of number of decimals...
The program does not determine the decimals on its own so I have to do sprintf(char*, "&#37;.*f", iDecimalPlaces, iInteger);

Do you have a solution for this?

5. sprintf() is what I would use

gg

6. Sorry still donīt get it... Just tried a few possibilities but all failed...

This is one of them sprintf(chTotal, "%f", iTotal);

Seems like sprintf always return 6 decimals even if they are equal to NULL.

7. Well, you can limit it to a fix number of decimals through
sprintf(chTotal, "&#37;0.2f", iTotal)
This will only use two decimals.

8. Yes that is actually my problem...
I need a function that determines for me number of decimals of the double type.
Then I use the returned value as you did

9. But the thing is that it will convert all decimals into a string, unless you specify otherwise.

10. All right

What else do you recommend me. I agree this is not the best solution in this case

11. The number of decimal points to show is completely up to you. What does the value represent? A measurement? Money?

Are you looking for locale dependant information - like the number of decimal points to show for a money value?

gg

12. I am creating a little calculator... So I need my answers to be in correct count of decimals...

If I process 1/8 it should return 0.125 not 0.125000 or 0
Sorry I did not state that its for calculator use before

13. Just pass &#37;f, and it will print any available decimals.
Beware that floating points in somewhat inaccurate, so 1/8 can also return 0.12500001 or something. Don't know if it can happen to this particular equation, but it can happen to certain ones.

14. 1/8 is integer - that's why it is 0

use 1.0/8 or 1/8.0

15. What Every Computer Scientist Should Know About Floating-Point Arithmetic

End the end, if you want exact precision - use a 3rd party library like GMP.

gg