(macOS) Fixed an issue where the battery capacity was not calculated correctly

This commit is contained in:
Leon Styhre 2025-02-24 20:18:56 +01:00
parent 4c06ef2dc3
commit eb3c45cbd9

View file

@ -382,8 +382,10 @@ void SystemStatus::getStatusBattery()
static_cast<CFNumberRef>(CFDictionaryGetValue(source, CFSTR(kIOPSMaxCapacityKey)))};
CFNumberGetValue(maxCapacityNum, kCFNumberIntType, &maxCapacity);
if (maxCapacity > 0)
batteryCapacity = curCapacity / maxCapacity * 100;
if (maxCapacity > 0) {
batteryCapacity =
static_cast<float>(curCapacity) / static_cast<float>(maxCapacity) * 100.0f;
}
}
}