From d0de678d57a2772369dc75d8f1f072173dd6e25b Mon Sep 17 00:00:00 2001 From: steve Date: Thu, 2 Feb 2006 05:48:45 +0000 Subject: [PATCH] real-to-integer conversions round, not truncate. --- vvp/vthread.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vvp/vthread.cc b/vvp/vthread.cc index f4bdfdad5..b0246128b 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: vthread.cc,v 1.151 2006/02/02 02:44:00 steve Exp $" +#ident "$Id: vthread.cc,v 1.152 2006/02/02 05:48:45 steve Exp $" #endif # include "config.h" @@ -968,7 +968,7 @@ bool of_CMPZ(vthread_t thr, vvp_code_t cp) bool of_CVT_IR(vthread_t thr, vvp_code_t cp) { double r = thr->words[cp->bit_idx[1]].w_real; - thr->words[cp->bit_idx[0]].w_int = (long)(r); + thr->words[cp->bit_idx[0]].w_int = lround(r); return true; } @@ -984,7 +984,7 @@ bool of_CVT_RI(vthread_t thr, vvp_code_t cp) bool of_CVT_VR(vthread_t thr, vvp_code_t cp) { double r = thr->words[cp->bit_idx[1]].w_real; - long rl = (long)r; + long rl = lround(r); unsigned base = cp->bit_idx[0]; unsigned wid = cp->number; @@ -3219,6 +3219,9 @@ bool of_JOIN_UFUNC(vthread_t thr, vvp_code_t cp) /* * $Log: vthread.cc,v $ + * Revision 1.152 2006/02/02 05:48:45 steve + * real-to-integer conversions round, not truncate. + * * Revision 1.151 2006/02/02 02:44:00 steve * Allow part selects of memory words in l-values. *