diff options
author | Taybin Rutkin <taybin@taybin.com> | 2005-08-11 19:45:29 +0000 |
---|---|---|
committer | Taybin Rutkin <taybin@taybin.com> | 2005-08-11 19:45:29 +0000 |
commit | f9546e5c76afa101e9dbe8a057e72463b03430e5 (patch) | |
tree | c8ff473dde0110d81b0076c0b68f2c218ffcb3be /libs | |
parent | 45866a0ab0ad66169f3e9ea111ede017a80fb3b5 (diff) |
Synced fastlog.h with ardour1 updates.
git-svn-id: svn://localhost/trunk/ardour2@16 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r-- | libs/pbd3/pbd/fastlog.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libs/pbd3/pbd/fastlog.h b/libs/pbd3/pbd/fastlog.h index 4e9050cb8b..4269705a44 100644 --- a/libs/pbd3/pbd/fastlog.h +++ b/libs/pbd3/pbd/fastlog.h @@ -11,14 +11,16 @@ static inline float fast_log2 (float val) /* don't use reinterpret_cast<> because that prevents this from being used by pure C code (for example, GnomeCanvasItems) */ - int * const exp_ptr = (int *)(&val); + union {float f; int i;} t; + t.f = val; + int * const exp_ptr = &t.i; int x = *exp_ptr; const int log_2 = ((x >> 23) & 255) - 128; x &= ~(255 << 23); x += 127 << 23; *exp_ptr = x; - val = ((-1.0f/3) * val + 2) * val - 2.0f/3; // (1) + val = ((-1.0f/3) * t.f + 2) * t.f - 2.0f/3; return (val + log_2); } |