Skip to content
Permalink
Browse files

endian conversion for binary read

  • Loading branch information
ubauer committed Nov 24, 2019
1 parent 3e375a7 commit 6a97e6c9e78a226abf4342d9b72bf1cc0235d775
Showing with 7 additions and 2 deletions.
  1. +7 −2 ripser.cpp
@@ -830,10 +830,15 @@ enum file_format {
BINARY
};

static const uint16_t endian_check(0xff00);
static const bool is_big_endian = *reinterpret_cast<const uint8_t*>(&endian_check);

template <typename T> T read(std::istream& input_stream) {
T result;
input_stream.read(reinterpret_cast<char*>(&result), sizeof(T));
return result; // on little endian: boost::endian::little_to_native(result);
char* p = reinterpret_cast<char*>(&result);
input_stream.read(p, sizeof(T));
if (is_big_endian) std::reverse(p, p + sizeof(T));
return result;
}

compressed_lower_distance_matrix read_point_cloud(std::istream& input_stream) {

0 comments on commit 6a97e6c

Please sign in to comment.
You can’t perform that action at this time.