dis[play capacity as double

This commit is contained in:
2022-01-26 16:31:46 +01:00
parent 77c7849484
commit 84e42a430b
2 changed files with 13 additions and 13 deletions

View File

@ -48,17 +48,17 @@ uint32_t Drive::getPowerCycles(void)
string Drive::sCapacityToText()
{
if(getCapacity() <= (999*1000000000UL))
{
// Less or even 999 GB --> GB
return to_string(getCapacity() / 1000000000UL) + " GB";
}
else
{
// More 999 GB --> TB
return to_string(getCapacity() / 1000000000000UL) + " TB";
}
return "ERROR";
char acBuffer[16];
double dSize = (double) getCapacity();
uint16_t u16UnitIndex = 0;
const char* units[] = {"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"};
while (dSize >= 1000) { //using the marketing capacity
dSize /= 1000;
u16UnitIndex++;
}
sprintf(acBuffer, "%.*f %s", u16UnitIndex-3, dSize, units[u16UnitIndex]);
return acBuffer;
}
string Drive::sErrorCountToText()