현재 데이터가 float 배열로 표시되고 데이터가 항상 little endian 표현으로 작성되어야하는 이진 파일 형식으로 작업 중입니다. 그래서, 현재 다음과 같은 것을합니다 :float 배열의 바이트 스와핑
float * swapped_array = new float[length_of_array];
for (int i = 0; i < length_of_array; ++i) {
swapped_array[i] = swap_float(input_array[i]);
}
여기서 swap_float는 부동 소수점 값의 4 바이트를 스왑합니다. 자,이 for 루프를 반복적으로 사용하고보다 계산 상 효율적으로 만들지 않고도 크로스 플랫폼 방식으로이 작업을 수행 할 수있는 방법이 있는지 궁금합니다.
'new'는 C++'소리'. 왜'c'라고 태그합니까? –
중복 질문 (조사 없음) : http://stackoverflow.com/questions/2782725/converting-float-values-from-big-endian-to-little-endian –
http://www.boost.org/doc/ libs/develops/libs/endian/doc/index.html – IdeaHat