sqldata/str.cpp
// Convert size in bytes to string with MB, GB
Convert size in bytes to string with MB, GB
Convert size in bytes to string with MB GB
char* Str::FormatByteSize(double bytes, char *output)
{
	if(output == NULL)
		return NULL;
	if(bytes <= 1024)
		sprintf(output, "%0.0lf bytes", bytes);
	else
	if(bytes > 1024 && bytes <= 1024 * 1024)
		sprintf(output, "%0.1lf KB", ((double)bytes)/1024.0);
	else
	if(bytes > 1024 * 1024 && bytes <= 1024 * 1024 * 1024)
		sprintf(output, "%0.1lf MB", ((double)bytes)/1024.0/1024.0);
	else
	sprintf(output, "%0.1lf GB", ((double)bytes)/1024.0/1024.0/1024.0);
	return output;
}
char * Str :: FormatByteSize ( double bytes , char * output ) { if ( output == NULL ) return NULL ; if ( bytes <= 1024 ) sprintf ( output , " " , bytes ) ; else if ( bytes > 1024 && bytes <= 1024 * 1024 ) sprintf ( output , " " , ( ( double ) bytes ) / 1024.0 ) ; else if ( bytes > 1024 * 1024 && bytes <= 1024 * 1024 * 1024 ) sprintf ( output , " " , ( ( double ) bytes ) / 1024.0 / 1024.0 ) ; else sprintf ( output , " " , ( ( double ) bytes ) / 1024.0 / 1024.0 / 1024.0 ) ; return output ; }
Convert size in bytes to string with MB, GB
Convert size in bytes to string with MB GB
// Output size in bytes // Output size in KB // Output size in MB // Output size in GB