From c032d28aaa3beba5e188aadf7dd538dc5d376997 Mon Sep 17 00:00:00 2001 From: Cary R Date: Fri, 15 Aug 2008 11:31:36 -0700 Subject: [PATCH] Convert the infinities to 'bx This patch modifies the double to vector conversions to return 'bx for either +/- infinity. --- verinum.cc | 13 ++----------- vvp/vvp_net.cc | 11 ++--------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/verinum.cc b/verinum.cc index 5bce5831a..b4f20f32e 100644 --- a/verinum.cc +++ b/verinum.cc @@ -162,23 +162,14 @@ verinum::verinum(double val, bool dummy) int exponent; const unsigned BITS_IN_LONG = 8*sizeof(long); - /* We return `bx for a NaN. */ - if (val != val) { + /* We return `bx for a NaN or +/- infinity. */ + if (val != val || (val && (val == 0.5*val))) { nbits_ = 1; bits_ = new V[nbits_]; bits_[0] = Vx; return; } - /* We return 'b1 for + infinity or 'b0 for - infinity. */ - if (val && (val == 0.5*val)) { - nbits_ = 1; - bits_ = new V[nbits_]; - if (val > 0) bits_[0] = V1; - else bits_[0] = V0; - return; - } - /* Convert to a positive result. */ if (val < 0.0) { is_neg = true; diff --git a/vvp/vvp_net.cc b/vvp/vvp_net.cc index a8c669e26..cead9a17b 100644 --- a/vvp/vvp_net.cc +++ b/vvp/vvp_net.cc @@ -372,19 +372,12 @@ vvp_vector4_t::vvp_vector4_t(unsigned size, double val) double fraction; int exponent; - /* We return 'bx for a NaN. */ - if (val != val) { + /* We return 'bx for a NaN or +/- infinity. */ + if (val != val || (val && (val == 0.5*val))) { allocate_words_(size, WORD_X_ABITS, WORD_X_BBITS); return; } - /* We return 'b1 for + infinity or 'b0 for - infinity. */ - if (val && (val == 0.5*val)) { - if (val > 0) allocate_words_(size, WORD_1_ABITS, WORD_1_BBITS); - else allocate_words_(size, WORD_0_ABITS, WORD_0_BBITS); - return; - } - /* Convert to a positive result. */ if (val < 0.0) { is_neg = true;