-#if 1
- int len = 1;
- static const char *suffix[] = { "", "K", "M", "G", "T", "P" };
- for( int64_t s=size; len<15 && (s/=10)>0; ++len );
- int drop = len-3;
- if( drop > 0 ) {
+ if( (size_format == FILEBOX_SIZE_1000 && size >= 1000) ||
+ (size_format == FILEBOX_SIZE_1024 && size >= 1024) ) {
+ static const char *suffix[] = { "", "K", "M", "G", "T", "P" };
+ if( size_format == FILEBOX_SIZE_1024 ) {
+ static const long double kk = logl(1000.)/logl(1024.);
+ size = expl(kk*logl((long double)size)) + 0.5;
+ }
+ int len = 1;
+ for( int64_t s=size; len<16 && (s/=10)>0; ++len );
+ int drop = len-3;