In my NMODL code
P_v-1 evaluates to -3.68653e-06
exp(-((t-tsyn)/tau_VDD)) evaluates to 6.14421e-06
((P_v-1) * exp(-((t-tsyn)/tau_VDD))) evaluates to -2.26508e-11
But 1 + ((P_v-1) * exp(-((t-tsyn)/tau_VDD))) evaluates to 1.
Is there some way to avoid this roundoff?
avoiding roundoff
Re: avoiding roundoff
How do you know it evaluated to 1? Did you print in %-20g format or (if you put it in a variable x), printed x-1?
Re: avoiding roundoff
I printed it in the %-20g format. Printing x-1 gives me the right answer (-2.26508e-11). Printing x*0.005 in %-20g gives me 0.005.
Re: avoiding roundoff
Sorry, my typo. I should have said "%.20g"
Re: avoiding roundoff
Thank you very much. Printing it out as %.20g gives me the right answer. I now understand that its got to do with the way %g is used.