Index: uspace/lib/math/arch/abs32le/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/abs32le/include/libarch/math.h	(revision b336613f992c18f8b2ee48fde947974ba750988e)
+++ uspace/lib/math/arch/abs32le/include/libarch/math.h	(revision c0c38c7c377b0a40d556f2b53fa830176a19d761)
@@ -41,15 +41,15 @@
 #include <trig.h>
 
-static inline double fmod(double dividend, double divisor)
+static inline float64_t fmod(float64_t dividend, float64_t divisor)
 {
-	return double_mod(dividend, divisor);
+	return float64_mod(dividend, divisor);
 }
 
-static inline double trunc(double val)
+static inline float64_t trunc(float64_t val)
 {
-	double_t arg;
+	float64_u arg;
 	arg.val = val;
 	
-	double_t ret;
+	float64_u ret;
 	ret.data = trunc_float64(arg.data);
 	
@@ -57,12 +57,12 @@
 }
 
-static inline double sin(double val)
+static inline float64_t sin(float64_t val)
 {
-	return double_sin(val);
+	return float64_sin(val);
 }
 
-static inline double cos(double val)
+static inline float64_t cos(float64_t val)
 {
-	return double_cos(val);
+	return float64_cos(val);
 }
 
Index: uspace/lib/math/arch/amd64/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/amd64/include/libarch/math.h	(revision b336613f992c18f8b2ee48fde947974ba750988e)
+++ uspace/lib/math/arch/amd64/include/libarch/math.h	(revision c0c38c7c377b0a40d556f2b53fa830176a19d761)
@@ -36,14 +36,15 @@
 #define LIBMATH_amd64_MATH_H_
 
+#include <mathtypes.h>
 #include <mod.h>
 
-static inline double fmod(double dividend, double divisor)
+static inline float64_t fmod(float64_t dividend, float64_t divisor)
 {
-	return double_mod(dividend, divisor);
+	return float64_mod(dividend, divisor);
 }
 
-extern double sin(double);
-extern double cos(double);
-extern double trunc(double);
+extern float64_t sin(float64_t);
+extern float64_t cos(float64_t);
+extern float64_t trunc(float64_t);
 
 #endif
Index: uspace/lib/math/arch/arm32/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/arm32/include/libarch/math.h	(revision b336613f992c18f8b2ee48fde947974ba750988e)
+++ uspace/lib/math/arch/arm32/include/libarch/math.h	(revision c0c38c7c377b0a40d556f2b53fa830176a19d761)
@@ -41,15 +41,15 @@
 #include <trig.h>
 
-static inline double fmod(double dividend, double divisor)
+static inline float64_t fmod(float64_t dividend, float64_t divisor)
 {
-	return double_mod(dividend, divisor);
+	return float64_mod(dividend, divisor);
 }
 
-static inline double trunc(double val)
+static inline float64_t trunc(float64_t val)
 {
-	double_t arg;
+	float64_u arg;
 	arg.val = val;
 	
-	double_t ret;
+	float64_u ret;
 	ret.data = trunc_float64(arg.data);
 	
@@ -57,12 +57,12 @@
 }
 
-static inline double sin(double val)
+static inline float64_t sin(float64_t val)
 {
-	return double_sin(val);
+	return float64_sin(val);
 }
 
-static inline double cos(double val)
+static inline float64_t cos(float64_t val)
 {
-	return double_cos(val);
+	return float64_cos(val);
 }
 
Index: uspace/lib/math/arch/ia32/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/ia32/include/libarch/math.h	(revision b336613f992c18f8b2ee48fde947974ba750988e)
+++ uspace/lib/math/arch/ia32/include/libarch/math.h	(revision c0c38c7c377b0a40d556f2b53fa830176a19d761)
@@ -36,14 +36,15 @@
 #define LIBMATH_ia32_MATH_H_
 
+#include <mathtypes.h>
 #include <mod.h>
 
-static inline double fmod(double dividend, double divisor)
+static inline float64_t fmod(float64_t dividend, float64_t divisor)
 {
-	return double_mod(dividend, divisor);
+	return float64_mod(dividend, divisor);
 }
 
-extern double sin(double);
-extern double cos(double);
-extern double trunc(double);
+extern float64_t sin(float64_t);
+extern float64_t cos(float64_t);
+extern float64_t trunc(float64_t);
 
 #endif
Index: uspace/lib/math/arch/ia64/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/ia64/include/libarch/math.h	(revision b336613f992c18f8b2ee48fde947974ba750988e)
+++ uspace/lib/math/arch/ia64/include/libarch/math.h	(revision c0c38c7c377b0a40d556f2b53fa830176a19d761)
@@ -41,15 +41,15 @@
 #include <trig.h>
 
-static inline double fmod(double dividend, double divisor)
+static inline float64_t fmod(float64_t dividend, float64_t divisor)
 {
-	return double_mod(dividend, divisor);
+	return float64_mod(dividend, divisor);
 }
 
-static inline double trunc(double val)
+static inline float64_t trunc(float64_t val)
 {
-	double_t arg;
+	float64_u arg;
 	arg.val = val;
 	
-	double_t ret;
+	float64_u ret;
 	ret.data = trunc_float64(arg.data);
 	
@@ -57,12 +57,12 @@
 }
 
-static inline double sin(double val)
+static inline float64_t sin(float64_t val)
 {
-	return double_sin(val);
+	return float64_sin(val);
 }
 
-static inline double cos(double val)
+static inline float64_t cos(float64_t val)
 {
-	return double_cos(val);
+	return float64_cos(val);
 }
 
Index: uspace/lib/math/arch/mips32/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/mips32/include/libarch/math.h	(revision b336613f992c18f8b2ee48fde947974ba750988e)
+++ uspace/lib/math/arch/mips32/include/libarch/math.h	(revision c0c38c7c377b0a40d556f2b53fa830176a19d761)
@@ -41,15 +41,15 @@
 #include <trig.h>
 
-static inline double fmod(double dividend, double divisor)
+static inline float64_t fmod(float64_t dividend, float64_t divisor)
 {
-	return double_mod(dividend, divisor);
+	return float64_mod(dividend, divisor);
 }
 
-static inline double trunc(double val)
+static inline float64_t trunc(float64_t val)
 {
-	double_t arg;
+	float64_u arg;
 	arg.val = val;
 	
-	double_t ret;
+	float64_u ret;
 	ret.data = trunc_float64(arg.data);
 	
@@ -57,12 +57,12 @@
 }
 
-static inline double sin(double val)
+static inline float64_t sin(float64_t val)
 {
-	return double_sin(val);
+	return float64_sin(val);
 }
 
-static inline double cos(double val)
+static inline float64_t cos(float64_t val)
 {
-	return double_cos(val);
+	return float64_cos(val);
 }
 
Index: uspace/lib/math/arch/mips32eb/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/mips32eb/include/libarch/math.h	(revision b336613f992c18f8b2ee48fde947974ba750988e)
+++ uspace/lib/math/arch/mips32eb/include/libarch/math.h	(revision c0c38c7c377b0a40d556f2b53fa830176a19d761)
@@ -41,15 +41,15 @@
 #include <trig.h>
 
-static inline double fmod(double dividend, double divisor)
+static inline float64_t fmod(float64_t dividend, float64_t divisor)
 {
-	return double_mod(dividend, divisor);
+	return float64_mod(dividend, divisor);
 }
 
-static inline double trunc(double val)
+static inline float64_t trunc(float64_t val)
 {
-	double_t arg;
+	float64_u arg;
 	arg.val = val;
 	
-	double_t ret;
+	float64_u ret;
 	ret.data = trunc_float64(arg.data);
 	
@@ -57,12 +57,12 @@
 }
 
-static inline double sin(double val)
+static inline float64_t sin(float64_t val)
 {
-	return double_sin(val);
+	return float64_sin(val);
 }
 
-static inline double cos(double val)
+static inline float64_t cos(float64_t val)
 {
-	return double_cos(val);
+	return float64_cos(val);
 }
 
Index: uspace/lib/math/arch/ppc32/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/ppc32/include/libarch/math.h	(revision b336613f992c18f8b2ee48fde947974ba750988e)
+++ uspace/lib/math/arch/ppc32/include/libarch/math.h	(revision c0c38c7c377b0a40d556f2b53fa830176a19d761)
@@ -41,15 +41,15 @@
 #include <trig.h>
 
-static inline double fmod(double dividend, double divisor)
+static inline float64_t fmod(float64_t dividend, float64_t divisor)
 {
-	return double_mod(dividend, divisor);
+	return float64_mod(dividend, divisor);
 }
 
 static inline double trunc(double val)
 {
-	double_t arg;
+	float64_u arg;
 	arg.val = val;
 	
-	double_t ret;
+	float64_u ret;
 	ret.data = trunc_float64(arg.data);
 	
@@ -57,12 +57,12 @@
 }
 
-static inline double sin(double val)
+static inline float64_t sin(float64_t val)
 {
-	return double_sin(val);
+	return float64_sin(val);
 }
 
-static inline double cos(double val)
+static inline float64_t cos(float64_t val)
 {
-	return double_cos(val);
+	return float64_cos(val);
 }
 
Index: uspace/lib/math/arch/sparc32/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/sparc32/include/libarch/math.h	(revision b336613f992c18f8b2ee48fde947974ba750988e)
+++ uspace/lib/math/arch/sparc32/include/libarch/math.h	(revision c0c38c7c377b0a40d556f2b53fa830176a19d761)
@@ -41,15 +41,15 @@
 #include <trig.h>
 
-static inline double fmod(double dividend, double divisor)
+static inline float64_t fmod(float64_t dividend, float64_t divisor)
 {
-	return double_mod(dividend, divisor);
+	return float64_mod(dividend, divisor);
 }
 
-static inline double trunc(double val)
+static inline float64_t trunc(float64_t val)
 {
-	double_t arg;
+	float64_u arg;
 	arg.val = val;
 	
-	double_t ret;
+	float64_u ret;
 	ret.data = trunc_float64(arg.data);
 	
@@ -57,12 +57,12 @@
 }
 
-static inline double sin(double val)
+static inline float64_t sin(float64_t val)
 {
-	return double_sin(val);
+	return float64_sin(val);
 }
 
-static inline double cos(double val)
+static inline float64_t cos(float64_t val)
 {
-	return double_cos(val);
+	return float64_cos(val);
 }
 
Index: uspace/lib/math/arch/sparc64/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/sparc64/include/libarch/math.h	(revision b336613f992c18f8b2ee48fde947974ba750988e)
+++ uspace/lib/math/arch/sparc64/include/libarch/math.h	(revision c0c38c7c377b0a40d556f2b53fa830176a19d761)
@@ -41,15 +41,15 @@
 #include <trig.h>
 
-static inline double fmod(double dividend, double divisor)
+static inline float64_t fmod(float64_t dividend, float64_t divisor)
 {
-	return double_mod(dividend, divisor);
+	return float64_mod(dividend, divisor);
 }
 
-static inline double trunc(double val)
+static inline float64_t trunc(float64_t val)
 {
-	double_t arg;
+	float64_u arg;
 	arg.val = val;
 	
-	double_t ret;
+	float64_u ret;
 	ret.data = trunc_float64(arg.data);
 	
@@ -57,12 +57,12 @@
 }
 
-static inline double sin(double val)
+static inline float64_t sin(float64_t val)
 {
-	return double_sin(val);
+	return float64_sin(val);
 }
 
-static inline double cos(double val)
+static inline float64_t cos(float64_t val)
 {
-	return double_cos(val);
+	return float64_cos(val);
 }
 
Index: uspace/lib/math/generic/mod.c
===================================================================
--- uspace/lib/math/generic/mod.c	(revision b336613f992c18f8b2ee48fde947974ba750988e)
+++ uspace/lib/math/generic/mod.c	(revision c0c38c7c377b0a40d556f2b53fa830176a19d761)
@@ -52,9 +52,9 @@
  *
  */
-double double_mod(double dividend, double divisor)
+float64_t float64_mod(float64_t dividend, float64_t divisor)
 {
 	// FIXME: replace with exact arithmetics
 	
-	double quotient = trunc(dividend / divisor);
+	float64_t quotient = trunc(dividend / divisor);
 	
 	return (dividend - quotient * divisor);
Index: uspace/lib/math/generic/trig.c
===================================================================
--- uspace/lib/math/generic/trig.c	(revision b336613f992c18f8b2ee48fde947974ba750988e)
+++ uspace/lib/math/generic/trig.c	(revision c0c38c7c377b0a40d556f2b53fa830176a19d761)
@@ -39,5 +39,5 @@
 
 /** Precomputed values for factorial (starting from 1!) */
-static double factorials[TAYLOR_DEGREE] = {
+static float64_t factorials[TAYLOR_DEGREE] = {
 	1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800,
 	479001600, 6227020800
@@ -56,8 +56,8 @@
  *
  */
-static double taylor_sin(double arg)
-{
-	double ret = 0;
-	double nom = 1;
+static float64_t taylor_sin(float64_t arg)
+{
+	float64_t ret = 0;
+	float64_t nom = 1;
 	
 	for (unsigned int i = 0; i < TAYLOR_DEGREE; i++) {
@@ -85,8 +85,8 @@
  *
  */
-static double taylor_cos(double arg)
-{
-	double ret = 1;
-	double nom = 1;
+static float64_t taylor_cos(float64_t arg)
+{
+	float64_t ret = 1;
+	float64_t nom = 1;
 	
 	for (unsigned int i = 0; i < TAYLOR_DEGREE; i++) {
@@ -114,5 +114,5 @@
  *
  */
-static double base_sin(double arg)
+static float64_t base_sin(float64_t arg)
 {
 	unsigned int period = arg / (M_PI / 4);
@@ -147,5 +147,5 @@
  *
  */
-static double base_cos(double arg)
+static float64_t base_cos(float64_t arg)
 {
 	unsigned int period = arg / (M_PI / 4);
@@ -156,5 +156,5 @@
 	case 1:
 	case 2:
-		return taylor_sin(arg - M_PI / 2);
+		return -taylor_sin(arg - M_PI / 2);
 	case 3:
 	case 4:
@@ -162,5 +162,5 @@
 	case 5:
 	case 6:
-		return -taylor_sin(arg - 3 * M_PI / 2);
+		return taylor_sin(arg - 3 * M_PI / 2);
 	default:
 		return taylor_cos(arg - 2 * M_PI);
@@ -177,7 +177,7 @@
  *
  */
-double double_sin(double arg)
-{
-	double base_arg = fmod(arg, 2 * M_PI);
+float64_t float64_sin(float64_t arg)
+{
+	float64_t base_arg = fmod(arg, 2 * M_PI);
 	
 	if (base_arg < 0)
@@ -196,7 +196,7 @@
  *
  */
-double double_cos(double arg)
-{
-	double base_arg = fmod(arg, 2 * M_PI);
+float64_t float64_cos(float64_t arg)
+{
+	float64_t base_arg = fmod(arg, 2 * M_PI);
 	
 	if (base_arg < 0)
Index: uspace/lib/math/include/mathtypes.h
===================================================================
--- uspace/lib/math/include/mathtypes.h	(revision b336613f992c18f8b2ee48fde947974ba750988e)
+++ uspace/lib/math/include/mathtypes.h	(revision c0c38c7c377b0a40d556f2b53fa830176a19d761)
@@ -191,51 +191,121 @@
 #endif
 
-typedef union {
-	float val;
-	
+
 #if defined(FLOAT_SIZE_32)
+
+#ifndef float32_t
+	#define float32_t  float
+#endif
+
+#elif defined(FLOAT_SIZE_64)
+
+#ifndef float64_t
+	#define float64_t  float
+#endif
+
+#elif defined(FLOAT_SIZE_96)
+
+#ifndef float96_t
+	#define float96_t  float
+#endif
+
+#elif defined(FLOAT_SIZE_128)
+
+#ifndef float128_t
+	#define float128_t  float
+#endif
+
+#endif
+
+
+#if defined(DOUBLE_SIZE_32)
+
+#ifndef float32_t
+	#define float32_t  double
+#endif
+
+#elif defined(DOUBLE_SIZE_64)
+
+#ifndef float64_t
+	#define float64_t  double
+#endif
+
+#elif defined(DOUBLE_SIZE_96)
+
+#ifndef float96_t
+	#define float96_t  double
+#endif
+
+#elif defined(DOUBLE_SIZE_128)
+
+#ifndef float128_t
+	#define float128_t  double
+#endif
+
+#endif
+
+
+#if defined(LONG_DOUBLE_SIZE_32)
+
+#ifndef float32_t
+	#define float32_t  long double
+#endif
+
+#elif defined(LONG_DOUBLE_SIZE_64)
+
+#ifndef float64_t
+	#define float64_t  long double
+#endif
+
+#elif defined(LONG_DOUBLE_SIZE_96)
+
+#ifndef float96_t
+	#define float96_t  long double
+#endif
+
+#elif defined(LONG_DOUBLE_SIZE_128)
+
+#ifndef float128_t
+	#define float128_t  long double
+#endif
+
+#endif
+
+
+#ifdef float32_t
+
+typedef union {
+	float32_t val;
 	float32 data;
-#elif defined(FLOAT_SIZE_64)
+} float32_u;
+
+#endif
+
+#ifdef float64_t
+
+typedef union {
+	float64_t val;
 	float64 data;
-#elif defined(FLOAT_SIZE_96)
+} float64_u;
+
+#endif
+
+#ifdef float96_t
+
+typedef union {
+	float96_t val;
 	float96 data;
-#elif defined(FLOAT_SIZE_128)
+} float96_u;
+
+#endif
+
+#ifdef float128_t
+
+typedef union {
+	float128_t val;
 	float128 data;
-#else
-	#error Unsupported float size
-#endif
-} float_t;
-
-typedef union {
-	double val;
-	
-#if defined(DOUBLE_SIZE_32)
-	float32 data;
-#elif defined(DOUBLE_SIZE_64)
-	float64 data;
-#elif defined(DOUBLE_SIZE_96)
-	float96 data;
-#elif defined(DOUBLE_SIZE_128)
-	float128 data;
-#else
-	#error Unsupported double size
-#endif
-} double_t;
-
-typedef union {
-	long double val;
-	
-#if defined(LONG_DOUBLE_SIZE_32)
-	float32 data;
-#elif defined(LONG_DOUBLE_SIZE_64)
-	float64 data;
-#elif defined(LONG_DOUBLE_SIZE_96)
-	float96 data;
-#elif defined(LONG_DOUBLE_SIZE_128)
-	float128 data;
-#else
-	#error Unsupported long double size
-#endif
-} long_double_t;
+} float128_u;
+
+#endif
 
 #endif
Index: uspace/lib/math/include/mod.h
===================================================================
--- uspace/lib/math/include/mod.h	(revision b336613f992c18f8b2ee48fde947974ba750988e)
+++ uspace/lib/math/include/mod.h	(revision c0c38c7c377b0a40d556f2b53fa830176a19d761)
@@ -36,5 +36,5 @@
 #define LIBMATH_MOD_H_
 
-extern double double_mod(double, double);
+extern float64_t float64_mod(float64_t, float64_t);
 
 #endif
Index: uspace/lib/math/include/trig.h
===================================================================
--- uspace/lib/math/include/trig.h	(revision b336613f992c18f8b2ee48fde947974ba750988e)
+++ uspace/lib/math/include/trig.h	(revision c0c38c7c377b0a40d556f2b53fa830176a19d761)
@@ -36,6 +36,6 @@
 #define LIBMATH_TRIG_H_
 
-extern double double_sin(double);
-extern double double_cos(double);
+extern float64_t float64_sin(float64_t);
+extern float64_t float64_cos(float64_t);
 
 #endif
