[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sc-dev] SF.net SVN: supercollider:[9622] trunk/Headers/plugin_interface/ SC_InlineUnaryOp.h
Revision: 9622
http://supercollider.svn.sourceforge.net/supercollider/?rev=9622&view=rev
Author: timblech
Date: 2009-12-17 09:07:33 +0000 (Thu, 17 Dec 2009)
Log Message:
-----------
use c99-style trunc
Signed-off-by: Tim Blechmann <tim@xxxxxxxxxx>
Modified Paths:
--------------
trunk/Headers/plugin_interface/SC_InlineUnaryOp.h
Modified: trunk/Headers/plugin_interface/SC_InlineUnaryOp.h
===================================================================
--- trunk/Headers/plugin_interface/SC_InlineUnaryOp.h 2009-12-16 09:57:47 UTC (rev 9621)
+++ trunk/Headers/plugin_interface/SC_InlineUnaryOp.h 2009-12-17 09:07:33 UTC (rev 9622)
@@ -24,6 +24,8 @@
#include "SC_Types.h"
#include "SC_Constants.h"
+#include <cmath>
+
///////////////////////////////////////////////////////////////////////////////////////
inline bool sc_isnan(float x)
@@ -197,18 +199,13 @@
inline float32 sc_trunc(float32 x)
{
- // truncFloat is a number which causes a loss of precision of
- // the fractional part.
- // NOTE: this will only work if the FPU is set to round downward.
- // That is NOT the default rounding mode. SC sets it to this mode.
- float32 tmp1 = x + truncFloat;
- float32 tmp2 = tmp1 - truncFloat;
- return tmp2;
+ return truncf(x);
}
inline float32 sc_frac(float32 x)
{
- return x - sc_trunc(x);
+ float32 intpart;
+ return std::modf(x, &intpart);
}
inline float32 sc_lg3interp(float32 x1, float32 a, float32 b, float32 c, float32 d)
@@ -408,18 +405,13 @@
inline float64 sc_trunc(float64 x)
{
- // truncDouble is a number which causes a loss of precision of
- // the fractional part.
- // NOTE: this will only work if the FPU is set to round downward.
- // That is NOT the default rounding mode. SC sets it to this mode.
- float64 tmp1 = x + truncDouble;
- float64 tmp2 = tmp1 - truncDouble;
- return tmp2;
+ return trunc(x);
}
inline float64 sc_frac(float64 x)
{
- return x - sc_trunc(x);
+ float64 intpart;
+ return std::modf(x, &intpart);
}
inline float64 sc_wrap1(float64 x)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
_______________________________________________
sc-dev mailing list
info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-dev/
search: https://listarc.bham.ac.uk/lists/sc-dev/search/