Index: branches/network/src/lib/network/converter.cc
===================================================================
--- branches/network/src/lib/network/converter.cc	(revision 6225)
+++ branches/network/src/lib/network/converter.cc	(revision 6228)
@@ -80,16 +80,53 @@
 
 /*!
+ * Converts an int into a byte-array and stores the result into a given byte-array
+ * @remarks: The int is stored in big-endian
+ * @param x: The int which is to convert
+ * @return: A byte-array that accords the given int value
+ */
+int Converter::intToByteArray(int x, byte* a, int length)
+{
+  if (length < INTSIZE)
+  {
+    PRINTF(1)("byte buffer to short to store an int. Needed length %i. Avaiable length %i", INTSIZE, length);
+    return -1;
+  }
+  
+  const int mod = 256; // = 2^8
+
+  int sgn;
+  if (x >= 0)
+    sgn = 1;
+  else
+  {
+    sgn = -1;
+    x = -x;
+  }
+
+  for (int i = 0; i < INTSIZE; i++)
+  {
+    a[i] = x % mod;
+    x /= mod;
+  }
+
+  if (sgn == -1)
+    a[INTSIZE - 1] += sgnadd;
+
+  return INTSIZE;
+}
+
+/*!
  * Converts a byte-array into an int
  * @param a: The byte-array which is to convert
  * @return: An int that accords the given byte-array
  */
-int Converter::byteArrayToInt(const byte* a)
+int Converter::byteArrayToInt(const byte* a, int* x)
 {
   int mult = 1;
   const int step = 256; // = 2 ^ 8
-  int result = 0;
+  *x = 0;
   for (int i = 0; i < INTSIZE - 1; i++)
   {
-    result += a[i] * mult;
+    *x += a[i] * mult;
     mult *= step;
   }
@@ -97,11 +134,11 @@
   if (a[INTSIZE - 1] >= sgnadd)
   {
-    result += (a[INTSIZE - 1] - sgnadd) * mult;
-    result *= -1;
-  }
-  else
-    result += a[INTSIZE - 1] * mult;
-
-  return result;
+    *x += (a[INTSIZE - 1] - sgnadd) * mult;
+    *x *= -1;
+  }
+  else
+    *x += a[INTSIZE - 1] * mult;
+
+  return INTSIZE;
 }
 
@@ -267,2 +304,103 @@
   return result;
 }
+
+/*!
+ * Converts a float value into a byte-array and stores the result into a given byte-array
+ * @param x: The float which is to convert
+ * @return: A byte-array which accords the given float
+ */
+int Converter::floatToByteArray(float x, byte* a, int length)
+{
+  if (length < FLOATSIZE)
+  {
+    PRINTF(1)("byte buffer to short to store a float. Needed length %i. Avaiable length %i", FLOATSIZE, length);
+    return -1;
+  }
+  int mantisse = 0;
+  int exponent = 128;
+
+  int sgn;
+  if (x < 0)
+  {
+    x = -x;
+    sgn = -1;
+  }
+  else
+    sgn = 1;
+
+  float sub = 1;
+  while (sub < x)
+  {
+    sub *= 2;
+    exponent++;
+  }
+
+  while (x > 0)
+  {
+    if (x >= sub)
+    {
+      mantisse += 1;
+      x -= sub;
+    }
+
+    mantisse *= 2;
+    exponent--;
+    sub /= 2;
+  }
+  exponent++;
+  mantisse /= 2;
+  while (mantisse < expmult)
+  {
+    mantisse *= 2;
+    exponent--;
+  }
+
+  //printf("mantisse = %i exponent = %i \n", mantisse, exponent);
+
+  mantisse -= expmult;
+
+  int hx = mantisse + expmult * exponent;
+  int result = intToByteArray(hx, a, length);
+  if (sgn == -1)
+    a[3] += sgnadd;
+
+  return result;
+}
+
+
+/*!
+ * Converts a byte-array into a float value
+ * @param a: The byte-array which is to convert
+ * @return: A float value which accords the given byte-array
+ */
+int Converter::byteArrayToFloat(byte* a, float* x)
+{
+  int hmant = a[0] + a[1] * 256 + a[2] * 65536;
+  int mantisse = hmant % expmult;
+  mantisse += expmult;
+
+  int hexp = a[2] + a[3] * 256;
+  int exponent = (hexp / 128) % 256 - 128;
+
+  int sgn;
+  if (a[3] >= sgnadd)
+    sgn = -1;
+  else
+    sgn = 1;
+
+  //printf("mantisse = %i exponent = %i \n", mantisse, exponent);
+
+  float emult = 1;
+  if (exponent > 0)
+    for (int i = 0; i < exponent; i++)
+      emult *= 2;
+  else if (exponent < 0)
+    for (int i = 0; i > exponent; i--)
+      emult /= 2;
+
+  *x = mantisse * emult;
+  if (sgn == -1)
+    *x = -  *x;
+
+  return FLOATSIZE;
+}
Index: branches/network/src/lib/network/converter.h
===================================================================
--- branches/network/src/lib/network/converter.h	(revision 6225)
+++ branches/network/src/lib/network/converter.h	(revision 6228)
@@ -15,4 +15,6 @@
 /* The size of an int in byte */
 #define INTSIZE 4
+/* The size of a float in byte */
+#define FLOATSIZE 4
 
 /*!
@@ -26,8 +28,8 @@
 
     static int intToByteArray(int x, byte* a, int length);
-    static int byteArrayToInt(byte* a, int* x);
+    static int byteArrayToInt(const byte* a, int* x);
 
-    static int floatToByteArray(float x, byte* a, int length);
-    static int byteArrayToFloat(byte* a, float* x);
+    static int floatToByteArray(float x, const byte* a, int length);
+    static int byteArrayToFloat(const byte* a, float* x);
     
     //Test
