Skip to content

Commit

Permalink
Slightly more elegant.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Oct 2, 2023
1 parent 4a2087b commit fc30850
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions include/uzuki2/parse_hdf5.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,21 +202,20 @@ inline double legacy_missing_double() {
double missing_value = 0;
auto missing_ptr = reinterpret_cast<unsigned char*>(&missing_value);

int start = 0;
int step = 1;
if (tmp_ptr[0] == 1) { // little-endian.
start = 7;
missing_ptr += sizeof(double) - 1;
step = -1;
}

missing_ptr[start] = 0x7f;
missing_ptr[start += step] = 0xf0;
missing_ptr[start += step] = 0x00;
missing_ptr[start += step] = 0x00;
missing_ptr[start += step] = 0x00;
missing_ptr[start += step] = 0x00;
missing_ptr[start += step] = 0x07;
missing_ptr[start += step] = 0xa2;
*missing_ptr = 0x7f;
*(missing_ptr += step) = 0xf0;
*(missing_ptr += step) = 0x00;
*(missing_ptr += step) = 0x00;
*(missing_ptr += step) = 0x00;
*(missing_ptr += step) = 0x00;
*(missing_ptr += step) = 0x07;
*(missing_ptr += step) = 0xa2;

return missing_value;
}
Expand Down

0 comments on commit fc30850

Please sign in to comment.