0
0

hello fellow coders 8)

here is my idea:

i am currently working with a own media player, made with "Windows forms" and vc++. all functions works fine except for one.
i wanted to have a cpu-meter in the form of a ‘progressbar’ or even simpler; a textfield, using getcpuusage.
the problem i face is that the value i get from the getcpuusage command gives me a float value, (such as 3.23232355758E-28) and it doesnt quite represent the value i want to put in my software :)

i tried to cast the float value into different int’s and such, but that gave me a very low value.
i have looked in the examples directory, but it did not help me a lot since it just does a DOS-based printf with the float.

so please, anyone know how to turn the float value into a integer without destroying it?

  • You must to post comments
0
0

if you cast that float value to an int, it would probably be 0. Thats what it should say. It is a very very small number (.03%) so you mightas well print 0

  • You must to post comments
0
0

(int)(value * 100.f), will give you it as a percentage. Or you could "%.2f" to print only the first 2 decimal places? How do you want it displayed?

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.