Changeset 6592 in orxonox.OLD for branches/network/src/lib
- Timestamp:
- Jan 18, 2006, 4:43:37 PM (19 years ago)
- Location:
- branches/network/src/lib/network
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/converter.cc
r6581 r6592 333 333 * @return: A byte-array which accords the given float 334 334 */ 335 int Converter:: floatToByteArray(float x, byte* a, int length)335 int Converter::_floatToByteArray(float x, byte* a, int length) 336 336 { 337 337 if (length < FLOATSIZE) … … 433 433 * @return: A float value which accords the given byte-array 434 434 */ 435 int Converter:: byteArrayToFloat(const byte* a, float* x)435 int Converter::_byteArrayToFloat(const byte* a, float* x) 436 436 { 437 437 //handle 0 … … 500 500 * @return: A byte-array which accords the given float 501 501 */ 502 byte* Converter::_floatToByteArray(float x) 503 { 502 int 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 } 504 509 byte* p = (byte*)&x; 505 byte* result = new byte[4]; 510 506 511 for (int i = 0; i < 4; i++) 507 result[i] = p[i];508 return result;512 a[i] = p[i]; 513 return 4; 509 514 } 510 515 … … 515 520 * @return: A float value which accords the given byte-array 516 521 */ 517 float Converter::_byteArrayToFloat(byte* a)518 { 519 float* p = (float*)a;520 float result = *p; 521 return result;522 int Converter::byteArrayToFloat(const byte* a, float* x) 523 { 524 *x = *((float*)a); 525 526 return 4; 522 527 } 523 528 -
branches/network/src/lib/network/converter.h
r6564 r6592 44 44 static float byteArrayToFloat(byte* a); 45 45 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 50 50 static void debug(); 51 51 static void floatTest(float x); 52 52 static float getDenormConst(); 53 54 53 54 55 55 private: 56 56 Converter();
Note: See TracChangeset
for help on using the changeset viewer.