From 4989afb153f88d4df3d59d2d82cc80924b6b72c6 Mon Sep 17 00:00:00 2001 From: Cary R Date: Fri, 11 Oct 2013 11:37:42 -0700 Subject: [PATCH] V0.9: Fix another real to vpiIntVal conversion in the run time --- vvp/vpi_vthr_vector.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/vvp/vpi_vthr_vector.cc b/vvp/vpi_vthr_vector.cc index b9c2206c0..71db5692c 100644 --- a/vvp/vpi_vthr_vector.cc +++ b/vvp/vpi_vthr_vector.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2010 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2013 Stephen Williams (steve@icarus.com) * Copyright (c) 2001 Stephan Boettcher * * This source code is free software; you can redistribute it @@ -540,7 +540,14 @@ static void vthr_real_get_value(vpiHandle ref, s_vpi_value*vp) break; case vpiIntVal: - vp->value.integer = (int)(val + 0.5); + /* NaN or +/- infinity are translated as 0. */ + if (val != val || (val && (val == 0.5*val))) { + val = 0.0; + } else { + if (val >= 0.0) val = floor(val + 0.5); + else val = ceil(val - 0.5); + } + vp->value.integer = val; break; case vpiDecStrVal: