Commit 1a6c31ee authored by Christoph Mallon's avatar Christoph Mallon
Browse files

tv: Correct converting NaNs.

Now the mantissa is correctly transferred, i.e. it is aligned at the most significant bit.
parent 1ae0a286
......@@ -724,9 +724,21 @@ void fc_cast(const fp_value *value, const float_descriptor_t *dest,
switch ((value_class_t)value->clss) {
case FC_NAN:
fc_get_nan(dest, result, !fc_nan_is_quiet(value), _mant(value));
case FC_NAN: {
result->desc = *dest;
result->clss = FC_NAN;
result->sign = value->sign;
sc_max_from_bits(dest->exponent_size, 0, _exp(result));
unsigned const src_mant = value->desc.mantissa_size;
unsigned const dst_mant = dest->mantissa_size;
if (dst_mant < src_mant) {
sc_shrI(_mant(value), src_mant - dst_mant, _mant(result));
} else {
sc_shlI(_mant(value), dst_mant - src_mant, _mant(result));
case FC_INF:
fc_get_inf(dest, result, value->sign);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment