Using a variable to set vector size - problem
Posted: Fri Apr 20, 2012 11:05 am
I'm encountering the following problem when using a variable to resize a vector. Briefly I use scanvar() to read in a value, then use this to calculate NtimeSteps. As you can see, NtimeSteps is initially 359, but tmpvec.resize(NtimeSteps) results in a vector with 358 elements. When I set NtimeSteps to 359 explicitly this problem goes away. What am I doing wrong? I'm guessing it's a rounding or precision error from the original calculation of NtimeSteps, but why can't I see it?
Code: Select all
oc>NtimeSteps 359 oc>objref tmpvec oc>tmpvec=new Vector() oc>tmpvec.resize(NtimeSteps) Vector oc>tmpvec.size 358 oc>NtimeSteps=359 oc>NtimeSteps 359 oc>tmpvec.resize(NtimeSteps) Vector oc>tmpvec.size 359 oc>