From 8696c81e7d322e7886d65faff377846b38084323 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 6 Jun 2018 01:53:41 +0200 Subject: [PATCH] Implement fast frexpf. --- server/TracyView.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index ca0e0c20..830a8ff5 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -153,10 +153,23 @@ static const char* RealToString( double val, bool separator ) return buf; } +tracy_force_inline float frexpf_fast( float f, int& power ) +{ + float ret; + int32_t fl; + memcpy( &fl, &f, 4 ); + power = ( fl >> 23 ) & 0x000000ff; + power -= 0x7e; + fl &= 0x807fffff; + fl |= 0x3f000000; + memcpy( &ret, &fl, 4 ); + return ret; +} + tracy_force_inline float log2fast( float x ) { int e; - auto f = frexpf( fabsf( x ), &e ); + auto f = frexpf_fast( fabsf( x ), e ); auto t0 = 1.23149591368684f * f - 4.11852516267426f; auto t1 = t0 * f + 6.02197014179219f; auto t2 = t1 * f - 3.13396450166353f;