Mostly fix a portability problem in $rtoi (run time)

This commit is contained in:
Cary R 2013-10-11 17:29:56 -07:00
parent 8f0687adb7
commit 12c588fc35
1 changed files with 4 additions and 2 deletions

View File

@ -215,8 +215,10 @@ static PLI_INT32 sys_rtoi_calltf(ICARUS_VPI_CONST PLI_BYTE8*user)
res.aval = ~(PLI_INT32)0;
res.bval = ~(PLI_INT32)0;
} else {
if (val >= 0.0) res.aval = (PLI_UINT32) val;
else res.aval = - (PLI_UINT32) -val;
/* This is not 100% correct since large real values may break this
* code. See the verinum code for a more rigorous implementation. */
if (val >= 0.0) res.aval = (PLI_UINT64) val;
else res.aval = - (PLI_UINT64) -val;
res.bval = 0;
}