no, it's not a ngspice bug. The same will probably happen in a C program.
In floating point arithmetic if you add many times 0.05 to a floating point number there are rounding errors.
Never check for a==b if a and b are floating point numbers and one of the two is the result of a calculation.
Test this C program:
#include <stdio.h>
int main(int argc, char *argv[])
{
double start_l = 1.0;
double stop_l = 1.5;
double delta_l = 0.05;
double act_l = start_l;
while( act_l <= stop_l) {
printf("act_l = %g\n", act_l);
act_l += delta_l;
}
return 0;
}
the output is:
schippes@asus:~$ ./test
act_l = 1
act_l = 1.05
act_l = 1.1
act_l = 1.15
act_l = 1.2
act_l = 1.25
act_l = 1.3
act_l = 1.35
act_l = 1.4
act_l = 1.45
You see the last iteration is not performed because the last
w_act
is not exactly 1.5 since adding 0,05 many times produces rounding errors. There is no exact representation of 0.05 in binary:
0,05 (dec) = 0.000011001100110011001100110011001100110011....(bin)