Code: Select all
oc>NtimeSteps
359
oc>objref tmpvec
oc>tmpvec=new Vector()
oc>tmpvec.resize(NtimeSteps)
Vector[1309]
oc>tmpvec.size
358
oc>NtimeSteps=359
oc>NtimeSteps
359
oc>tmpvec.resize(NtimeSteps)
Vector[1309]
oc>tmpvec.size
359
oc>
Code: Select all
oc>NtimeSteps
359
oc>objref tmpvec
oc>tmpvec=new Vector()
oc>tmpvec.resize(NtimeSteps)
Vector[1309]
oc>tmpvec.size
358
oc>NtimeSteps=359
oc>NtimeSteps
359
oc>tmpvec.resize(NtimeSteps)
Vector[1309]
oc>tmpvec.size
359
oc>
-5.6843419e-14ted wrote:At the oc> prompt, type this
NtimeSteps-359
then press the "Enter" key.
What do you see?
Treats it the same way int() would.Qroid_montreal wrote:Vector.resize(n) floors n, right?
Not necessarily. Your problem most likely arose from something that hasn't yet been disclosed in this thread.If so, is it generally a good technique to use n+0.5 when resizing?
Which begs two questions:I use scanvar() to read in a value, then use this to calculate NtimeSteps.
I wouldn't bother doing that if n is guaranteed to have an integer value. If it isn't, I'd pass int(n+0.5) as the argument to resize()--why leave anything to chance?is it generally a good technique to use n+0.5 when resizing?