Re: [ng-spice-devel] ACS with the "free" Borland compiler
"rint" is round-to-int, but it returns a double. You can define it
as:
inline double rint(double x) {return floor(x+.5);}
I put it in md.h, with a flag to activate it.
As to the rounding modes .... it really doesn't matter. You might
sometimes get a slightly different result, but it is noise. Its use
in ACS is to de-noise the printed result. Suppose I have two nodes,
with voltages 300.001 and 300.002 and I print the difference. The
use of "rint" is so it will print .001 as the result, instead of
.00099992462374236543.
Part of the purpose of the de-noising is so when I run benchmarks on
different systems the results are more likely to be the same. It is
annoying to do regression tests, and find a result that is
1.343443e-44 on one system and 5.7324223e-38 on another, when the
correct result is zero. It is still a problem, but less so now.
on the "floating point error" .... You found a real bug. It is
possible to get a divide by zero when the area of a diode is zero.
The reason I never caught it is the inconsistency in how compilers
handle divide by zero. As far as I know, the C++ standard does not
define what happens. With gcc on Linux, you get a result of infinity
and the program continues. It this case, it appeared harmless
because rs is not used anywhere. (incomplete work.) With Borland,
apparently it caused the program to stop.
Since it is not used anywhere, fake it by commenting out the line or
using (area+1e-20) instead of area, or something like that.
The diode code in 0.28 is a big mess, but I didn't worry about it
because it will be replaced by automatically generated code from the
model compiler in the next release, which is slow in coming because
IBIS support is taking lots of time.
Partial thread listing: