Weird behavior of STR2NUM after calling PAUSE
Marcus Vinicius Eiffle Duarte
eiffleduarte at gmail.com
Mon Mar 3 13:42:24 CST 2008
Hey, folks!
I was tweaking the UI of an old program of mine that (i) reads sets of text
files that contain numerical data listed in lines and (ii) extract some
numbers from some columns, process them and save these values to another
files, that will be used by other programs. As these file readings and data
extraction procedures take some time, I changed the program to show the time
elapsed between start and end of each data file processing, using tic() and
toc(). After this change, the output was very weird. After some
investigation, I discovered that after calling PAUSE, the str2num function
behaved in a different way, returning the integer part of the strings read
from the files. I frequently use some pause calls while writing new code (or
changing old code) to read intermediate results, and was being confused by
this.
I introduced a very simple test in the code I am running:
<--- Lots of code before --->
disp( 'BEFORE CALLING TIC , str2num(1.99) = ' )
str2num('1.99')
tic();
disp( 'AFTER CALLING TIC: , str2num(1.99) = ' )
str2num('1.99')
pause
disp( 'AFTER CALLING PAUSE: , str2num(1.99) = ' )
str2num('1.99')
pause
<--- Lots of code after --->
The output of this code shows the strange behavior of str2num:
<--- some output -->
BEFORE CALLING TIC , str2num(1.99) =
ans = 1.9900
AFTER CALLING TIC: , str2num(1.99) =
ans = 1.9900
AFTER CALLING PAUSE: , str2num(1.99) =
ans = 1
After this, any subsequent call to str2num produces the same behavior, even
in interactive mode, after the program finishes. If I just start octave and
try something similar, I can reproduce this erratic behavior, as shown in
the next lines
octave:1> str2num('1.991')
ans = 1.9910
octave:2> pause
octave:3> str2num('1.991')
ans = 1
I am using octave 3.0.0, compiled from source on Ubuntu 7.10. Can anyone
help me solve this strange behavior?
Thanks,
--
Marcus Vinicius Eiffle Duarte
eiffleduarte at gmail.com
Niterói, RJ, Brasil
Fernando Gabeira para prefeito do Rio em 2008
http://pedrodoria.com.br/2008/01/18/gabeira-para-o-rio/
http://www.slglab.com.br/gabeira/
http://www.orkut.com/Community.aspx?cmm=49521798
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.cae.wisc.edu/pipermail/help-octave/attachments/20080303/8b1d6b84/attachment.html
More information about the Help-octave
mailing list