title: How to correctly get a per process percent of used CPU using the SIGAR libraries
body: <p>I'm writing a code to get a per process percent of used CPU, but something is wrong with my code. That displays strange values like 3.63499e+262 % and 0%, while the task manager displays a value bigger than 0% and lower or equal a 100%. What i'm doing wrong?</p>
  
  <pre><code>sigar_t *sigarproclist;
  sigar_proc_list_t proclist;
  sigar_open(&amp;sigarproclist);
  sigar_proc_list_get(sigarproclist, &amp;proclist);
  for (size_t i = 0; i &lt; proclist.number; i++)
  {
      sigar_proc_cpu_t cpu;
      sigar_proc_cpu_get(sigarproclist, proclist.data[i], &amp;cpu);
      sigar_proc_state_t procstate;
      sigar_proc_state_get(sigarproclist, proclist.data[i], &amp;procstate);
      qDebug() &lt;&lt; procstate.name &lt;&lt; 100 * cpu.percent &lt;&lt; "%";
  }
  sigar_close(sigarproclist);
  </code></pre>