Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/wolfpld/tracy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartosz Taudul <wolf.pld@gmail.com>2020-01-31 03:19:08 +0300
committerBartosz Taudul <wolf.pld@gmail.com>2020-01-31 03:19:08 +0300
commit36fb1f96e2ccc151013e6ca7dfbb0eb8559826a2 (patch)
tree6ed9a322aa507bbcc1c897648666510e7604e2d3 /server/TracyPrint.cpp
parent8d5f4d7363fab25a336611f181b6b3d5b2f5e1a4 (diff)
Custom float-printing function.
Diffstat (limited to 'server/TracyPrint.cpp')
-rw-r--r--server/TracyPrint.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/server/TracyPrint.cpp b/server/TracyPrint.cpp
index 229ca194..fde2d0a4 100644
--- a/server/TracyPrint.cpp
+++ b/server/TracyPrint.cpp
@@ -280,29 +280,28 @@ const char* MemSizeToString( int64_t val )
};
Unit unit;
+ char* ptr;
if( aval < 10000ll * 1024 )
{
- sprintf( buf, "%.2f", val / 1024. );
+ ptr = PrintFloat( buf, buf+64, val / 1024., 2 );
unit = Unit::Kilobyte;
}
else if( aval < 10000ll * 1024 * 1024 )
{
- sprintf( buf, "%.2f", val / ( 1024. * 1024 ) );
+ ptr = PrintFloat( buf, buf+64, val / ( 1024. * 1024 ), 2 );
unit = Unit::Megabyte;
}
else if( aval < 10000ll * 1024 * 1024 * 1024 )
{
- sprintf( buf, "%.2f", val / ( 1024. * 1024 * 1024 ) );
+ ptr = PrintFloat( buf, buf+64, val / ( 1024. * 1024 * 1024 ), 2 );
unit = Unit::Gigabyte;
}
else
{
- sprintf( buf, "%.2f", val / ( 1024. * 1024 * 1024 * 1024 ) );
+ ptr = PrintFloat( buf, buf+64, val / ( 1024. * 1024 * 1024 * 1024 ), 2 );
unit = Unit::Terabyte;
}
- auto ptr = buf;
- while( *ptr ) ptr++;
ptr--;
while( ptr >= buf && *ptr == '0' ) ptr--;
if( *ptr != '.' ) ptr++;