Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6592 in orxonox.OLD


Ignore:
Timestamp:
Jan 18, 2006, 4:43:37 PM (18 years ago)
Author:
rennerc
Message:
 
Location:
branches/network/src/lib/network
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/network/converter.cc

    r6581 r6592  
    333333 * @return: A byte-array which accords the given float
    334334 */
    335 int Converter::floatToByteArray(float x, byte* a, int length)
     335int Converter::_floatToByteArray(float x, byte* a, int length)
    336336{
    337337  if (length < FLOATSIZE)
     
    433433 * @return: A float value which accords the given byte-array
    434434 */
    435 int Converter::byteArrayToFloat(const byte* a, float* x)
     435int Converter::_byteArrayToFloat(const byte* a, float* x)
    436436{
    437437    //handle 0
     
    500500 * @return: A byte-array which accords the given float
    501501 */
    502 byte* Converter::_floatToByteArray(float x)
    503 {
     502int Converter::floatToByteArray(float x, byte* a, int length)
     503{
     504  if ( length<4 )
     505  {
     506    PRINTF(1)("Byte Array to small\n");
     507    return 0;
     508  }
    504509  byte* p = (byte*)&x;
    505   byte* result = new byte[4];
     510
    506511  for (int i = 0; i < 4; i++)
    507     result[i] = p[i];
    508   return result;
     512    a[i] = p[i];
     513  return 4;
    509514}
    510515
     
    515520 * @return: A float value which accords the given byte-array
    516521 */
    517 float Converter::_byteArrayToFloat(byte* a)
    518 {
    519   float* p = (float*)a;
    520   float result = *p;
    521   return result;
     522int Converter::byteArrayToFloat(const byte* a, float* x)
     523{
     524  *x = *((float*)a);
     525
     526  return 4;
    522527}
    523528
  • branches/network/src/lib/network/converter.h

    r6564 r6592  
    4444    static float byteArrayToFloat(byte* a);
    4545
    46     static byte* _floatToByteArray(float x);
    47     static float _byteArrayToFloat(byte* a);
    48    
    49    
     46    static int _floatToByteArray(float x, byte* a, int length);
     47    static int _byteArrayToFloat(const byte* a, float* x);
     48
     49
    5050    static void debug();
    5151    static void floatTest(float x);
    5252    static float getDenormConst();
    53  
    54    
     53
     54
    5555  private:
    5656    Converter();
Note: See TracChangeset for help on using the changeset viewer.