diff --git a/src/util/format/u_format_pack.py b/src/util/format/u_format_pack.py index 94b326e6d82..83702a04a07 100644 --- a/src/util/format/u_format_pack.py +++ b/src/util/format/u_format_pack.py @@ -414,11 +414,14 @@ def conversion_expr(src_channel, if dst_channel.norm or dst_channel.type == FIXED: dst_one = get_one(dst_channel) if dst_channel.size <= 23: - value = 'util_iround(%s * 0x%x)' % (value, dst_one) + value = '(%s * 0x%x)' % (value, dst_one) else: # bigger than single precision mantissa, use double value = '(%s * (double)0x%x)' % (value, dst_one) + if dst_channel.size <= 23: + value = 'util_iround(%s)' % (value) + # Cast to an integer with the correct signedness first if dst_channel.type == UNSIGNED: value = '(uint%u_t)(%s) ' % (max(dst_channel.size, 32), value)