diff --git a/src/common/utils/convertCpu.ts b/src/common/utils/convertCpu.ts index e20a260e0d..86b57b78f8 100644 --- a/src/common/utils/convertCpu.ts +++ b/src/common/utils/convertCpu.ts @@ -20,7 +20,7 @@ const unitConverters = new Map([ ["E", 1000 ** 6], ]); -const cpuUnitsRegex = TypedRegEx("^(?\\d+)(?.*)$"); +const cpuUnitsRegex = TypedRegEx("^(?[+-]?[0-9.]+(e[-+]?[0-9]+)?)(?[EinumkKMGTP]*)$"); export function cpuUnitsToNumber(value: string) { const match = cpuUnitsRegex.captures(value); @@ -29,12 +29,12 @@ export function cpuUnitsToNumber(value: string) { return undefined; } - const { digits, unit } = match; + const { digits = "", unit } = match; const conversion = unitConverters.get(unit); if (conversion === undefined) { return undefined; } - return parseInt(digits) * conversion; + return parseFloat(digits) * conversion; }