Changeset 6197 in orxonox.OLD for branches/network/src/subprojects
- Timestamp:
- Dec 20, 2005, 6:18:14 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/subprojects/network/network_unit_test.cc
r6139 r6197 284 284 } 285 285 286 286 void testFloatConverter(float f) 287 { 288 char* s = Converter::floatToBinString(f); 289 printf("%f = ", f); 290 printf(s); printf("\n"); 291 292 byte* res = Converter::floatToByteArray(f); 293 printf("Byte Array: "); 294 for (int i = 0; i < 4; i++) 295 printf("%i ", res[i]); 296 printf("\n"); 297 298 float b = Converter::byteArrayToFloat(res); 299 printf("ReConvert: %f \n", b); 300 } 301 302 void testFloatConverter2(float f) 303 { 304 char* s = Converter::floatToBinString(f); 305 printf("### %f = ", f); 306 printf(s); printf("\n"); 307 308 byte* res = Converter::_floatToByteArray(f); 309 printf("Byte Array: "); 310 for (int i = 0; i < 4; i++) 311 printf("%i ", res[i]); 312 printf("\n"); 313 314 float b = Converter::_byteArrayToFloat(res); 315 printf("ReConvert: %f \n", b); 316 } 287 317 int converter(int argc, char** argv) 288 318 { 319 /* 289 320 int x = 200564786; 290 321 printf("To convert: %i\n", x); … … 305 336 printf("\n"); 306 337 338 */ 339 /* 307 340 float y; 308 341 char* s; … … 328 361 printf(s); printf("\n"); 329 362 330 363 y = -4.7824f; 364 s = Converter::floatToBinString(y); 365 printf("%f = ", y); 366 printf(s); printf("\n"); 367 368 y = -14.35e14f; 369 s = Converter::floatToBinString(y); 370 printf("%f = ", y); 371 printf(s); printf("\n"); 372 */ 373 374 375 /* 376 float a = 12.3f; 377 378 char* s = Converter::floatToBinString(a); 379 printf("%f = ", a); 380 printf(s); printf("\n"); 381 382 byte* res = Converter::floatToByteArray(a); 383 printf("Byte Array: \n"); 384 for (int i = 0; i < 4; i++) 385 printf("%i ", res[i]); 386 printf("\n"); 387 388 float b = Converter::byteArrayToFloat(res); 389 printf("ReConvert: %f \n", b); 390 */ 391 testFloatConverter2(12.3f); printf("\n"); 392 testFloatConverter2(134.25f); printf("\n"); 393 testFloatConverter2(35.67e14f); printf("\n"); 331 394 332 395 return 0;
Note: See TracChangeset
for help on using the changeset viewer.