From 4aa36912c426ab3f682b973f6be6e883bedc722b Mon Sep 17 00:00:00 2001 From: Jordan Henderson Date: Wed, 3 Jul 2024 16:55:08 -0500 Subject: [PATCH] fix BE swap issue --- src/H5Tconv_integer.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/H5Tconv_integer.c b/src/H5Tconv_integer.c index 1599f749420..3d43166864d 100644 --- a/src/H5Tconv_integer.c +++ b/src/H5Tconv_integer.c @@ -819,8 +819,16 @@ H5T__conv_i_f_loop(const H5T_t *src_p, const H5T_t *dst_p, const H5T_conv_ctx_t * complex value. */ if (H5T_ORDER_BE == dst_atomic.order && reverse) { - for (size_t i = 0; i < dst_p->shared->size / 2; i++) - H5_SWAP_BYTES(d, i, dst_p->shared->size - (i + 1)); + size_t half_size = dst_p->shared->size / 2; + + if (H5T_FLOAT == dst_p->shared->type) { + for (size_t i = 0; i < half_size; i++) + H5_SWAP_BYTES(d, i, dst_p->shared->size - (i + 1)); + } + else { + for (size_t i = 0; i < half_size / 2; i++) + H5_SWAP_BYTES(d, i, half_size - (i + 1)); + } } else if (H5T_ORDER_VAX == dst_atomic.order && reverse) { if (H5T_FLOAT == dst_p->shared->type) {