summaryrefslogtreecommitdiffstats
path: root/apps/plugins/pdbox
diff options
context:
space:
mode:
authorWincent Balin <wincent@rockbox.org>2009-07-29 21:35:38 +0000
committerWincent Balin <wincent@rockbox.org>2009-07-29 21:35:38 +0000
commitf95dc688cfbea5b3355bee0436767a8add8602d2 (patch)
tree360093b6f8b69077adaa7f8a621c8a10b9bc4570 /apps/plugins/pdbox
parent2fb73842a9b51e554a3a14feb0b4c0814c82ebec (diff)
downloadrockbox-f95dc688cfbea5b3355bee0436767a8add8602d2.tar.gz
rockbox-f95dc688cfbea5b3355bee0436767a8add8602d2.tar.bz2
rockbox-f95dc688cfbea5b3355bee0436767a8add8602d2.zip
Minor additions to floating point math functions.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22086 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/pdbox')
-rw-r--r--apps/plugins/pdbox/pdbox-func.c49
1 files changed, 19 insertions, 30 deletions
diff --git a/apps/plugins/pdbox/pdbox-func.c b/apps/plugins/pdbox/pdbox-func.c
index c5e81ed7b9..22c8714b3f 100644
--- a/apps/plugins/pdbox/pdbox-func.c
+++ b/apps/plugins/pdbox/pdbox-func.c
@@ -333,11 +333,19 @@ long rb_atol(const char* str)
float rb_sin(float rad)
{
+ int cycles;
+
/* Trim input value to -PI..PI interval. */
- if(rad < -3.14159265)
- rad += 6.28318531;
- else if(rad > 3.14159265)
- rad -= 6.28318531;
+ if(rad > 3.14159265)
+ {
+ cycles = rad / 6.28318531;
+ rad -= (6.28318531 * (float) cycles);
+ }
+ else if(rad < -3.14159265)
+ {
+ cycles = rad / -6.28318531;
+ rad += (6.28318531 * (float) cycles);
+ }
if(rad < 0)
return (1.27323954 * rad + 0.405284735 * rad * rad);
@@ -348,11 +356,7 @@ float rb_sin(float rad)
float rb_cos(float rad)
{
/* Compute cosine: sin(x + PI/2) = cos(x) */
- rad += 1.57079632;
- if(rad > 3.14159265)
- rad -= 6.28318531;
-
- return rb_sin(rad);
+ return rb_sin(rad + 1.57079632);
}
@@ -2108,54 +2112,39 @@ union ieee754_double
/* This is the IEEE 754 double-precision format. */
struct
{
-#if defined(ROCKBOX_BIG_ENDIAN)
+#ifdef ROCKBOX_BIG_ENDIAN
unsigned int negative:1;
unsigned int exponent:11;
/* Together these comprise the mantissa. */
unsigned int mantissa0:20;
unsigned int mantissa1:32;
-#else
-# if __FLOAT_WORD_ORDER == __BIG_ENDIAN
- unsigned int mantissa0:20;
- unsigned int exponent:11;
- unsigned int negative:1;
- unsigned int mantissa1:32;
-# else
+#else /* ROCKBOX_LITTLE_ENDIAN */
/* Together these comprise the mantissa. */
unsigned int mantissa1:32;
unsigned int mantissa0:20;
unsigned int exponent:11;
unsigned int negative:1;
-# endif
-#endif /* Little endian. */
+#endif /* ROCKBOX_LITTLE_ENDIAN */
} ieee;
/* This format makes it easier to see if a NaN is a signalling NaN. */
struct
{
-#if defined(ROCKBOX_BIG_ENDIAN)
+#ifdef ROCKBOX_BIG_ENDIAN
unsigned int negative:1;
unsigned int exponent:11;
unsigned int quiet_nan:1;
/* Together these comprise the mantissa. */
unsigned int mantissa0:19;
unsigned int mantissa1:32;
-#else
-# if __FLOAT_WORD_ORDER == __BIG_ENDIAN
- unsigned int mantissa0:19;
- unsigned int quiet_nan:1;
- unsigned int exponent:11;
- unsigned int negative:1;
- unsigned int mantissa1:32;
-# else
+#else /* ROCKBOX_LITTLE_ENDIAN */
/* Together these comprise the mantissa. */
unsigned int mantissa1:32;
unsigned int mantissa0:19;
unsigned int quiet_nan:1;
unsigned int exponent:11;
unsigned int negative:1;
-# endif
-#endif
+#endif /* ROCKBOX_LITTLE_ENDIAN */
} ieee_nan;
};