diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2009-11-10 20:59:05 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2009-11-10 20:59:05 +0000 |
commit | 33b135d7fc381a22965586e0567ede4da11eade3 (patch) | |
tree | fd798bef475c1ab6d92b4f888168524c77998141 /externals/vanilla/e_sqrt.c | |
parent | ef93be430a3794eea061d6494205739c218898c0 (diff) |
use renamed header d_math.h -> e_sqrt.h
svn path=/trunk/; revision=12748
Diffstat (limited to 'externals/vanilla/e_sqrt.c')
-rw-r--r-- | externals/vanilla/e_sqrt.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/externals/vanilla/e_sqrt.c b/externals/vanilla/e_sqrt.c new file mode 100644 index 00000000..eb011a4a --- /dev/null +++ b/externals/vanilla/e_sqrt.c @@ -0,0 +1,32 @@ +/* Copyright (c) 1997-2001 Miller Puckette and others. +* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* sqrt-related functions from pd-vanilla's d_math.c */ + +#include "e_sqrt.h" + + /* these are used in externs like "bonk" */ + +t_float q8_rsqrt(t_float f) +{ + long l = *(long *)(&f); + if (f < 0) return (0); + else return (rsqrt_exptab[(l >> 23) & 0xff] * + rsqrt_mantissatab[(l >> 13) & 0x3ff]); +} + +t_float q8_sqrt(t_float f) +{ + long l = *(long *)(&f); + if (f < 0) return (0); + else return (f * rsqrt_exptab[(l >> 23) & 0xff] * + rsqrt_mantissatab[(l >> 13) & 0x3ff]); +} + + /* the old names are OK unless we're in IRIX N32 */ + +#ifndef N32 +t_float qsqrt(t_float f) {return (q8_sqrt(f)); } +t_float qrsqrt(t_float f) {return (q8_rsqrt(f)); } +#endif |