summaryrefslogtreecommitdiffhomepage
path: root/ir/tv
diff options
context:
space:
mode:
authorChristoph Mallon <mallon@cs.uni-saarland.de>2015-02-01 19:21:16 +0100
committerChristoph Mallon <mallon@cs.uni-saarland.de>2015-02-01 19:21:16 +0100
commit1a6c31eeccda78baee074900dd9f24abd102d377 (patch)
treea122374ea3c8ab9831200f06f4700a7944ddee86 /ir/tv
parent1ae0a2867498132967b7bc7bf5f0834e3d4f8a59 (diff)
tv: Correct converting NaNs.
Now the mantissa is correctly transferred, i.e. it is aligned at the most significant bit.
Diffstat (limited to 'ir/tv')
-rw-r--r--ir/tv/fltcalc.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/ir/tv/fltcalc.c b/ir/tv/fltcalc.c
index 8699683..24e3178 100644
--- a/ir/tv/fltcalc.c
+++ b/ir/tv/fltcalc.c
@@ -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));
+ }
return;
+ }
+
case FC_INF:
fc_get_inf(dest, result, value->sign);
return;