Skip to content Skip to sidebar Skip to footer

Convert Khz Value From Cpu Into Mhz Or Ghz

I want to convert the String (result) of the following function into an Integer value and divide it by 1000 (khz -> mhz) private String ReadCPUMhz() { ProcessBuilder cmd; Stri

Solution 1:

Before converting that numbrer to int, remove all non numeric characters using something like this:

int khz = result.replace("[^0-9]+", "");

Then conver khz to number and divide it by 1000.

Post a Comment for "Convert Khz Value From Cpu Into Mhz Or Ghz"