help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Weird behavior of STR2NUM after calling PAUSE


From: Marcus Vinicius Eiffle Duarte
Subject: Weird behavior of STR2NUM after calling PAUSE
Date: Mon, 3 Mar 2008 16:42:24 -0300

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
address@hidden
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
reply via email to

[Prev in Thread] Current Thread [Next in Thread]