bugGNU Octave - Bugs: bug #40396, toc precision

 
 

bug #40396: toc precision

Submitter:  None
Submitted:  Mon 28 Oct 2013 01:26:22 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Inaccurate Result
Status:  Fixed Assigned to:  jwe
Originator Name:  Michael Leitner Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 01 Nov 2013 01:53:54 AM UTC, comment #5: 

Yeah yours is a much more thorough fix. As long as Octave is well-behaved within itself I'd call this fixed.

Mike Miller <mtmiller>
Group Member
Thu 31 Oct 2013 09:47:28 PM UTC, comment #4: 

Mike, I thought about fixing this by forcing the precision in teh toc output, but then decided it would be better to try to ensure that operations on octave_stdout don't set any persistent stream state.

I checked in the following changeset:

  http://hg.savannah.gnu.org/hgweb/octave/rev/f1b59ef34eda

OTOH, we can't prevent people from setting and not restoring the state in .oct files.  So maybe we should also set that format in the toc function...

John W. Eaton <jwe>
Group administrator
Wed 30 Oct 2013 07:48:30 AM UTC, comment #3: 

I've attached a diff that works for me. Let me know if this is good enough or if you'd rather fix it in the octave_stdout stream instead.

(file #29505)

Mike Miller <mtmiller>
Group Member
Wed 30 Oct 2013 07:29:12 AM UTC, comment #2: 

The problem is that the precision for the octave_stdout stream is being set but not restored in at least one function in pr-output.cc.  I'll take a look at fixing this if no one beats me to it.

John W. Eaton <jwe>
Group administrator
Tue 29 Oct 2013 01:28:28 AM UTC, comment #1: 

Confirmed, also present in development version:


octave-cli:1> tic; sleep (1.5); toc
Elapsed time is 1.50043 seconds.
octave-cli:2> 0
ans = 0
octave-cli:3> tic; sleep (1.5); toc
Elapsed time is 2 seconds.
octave-cli:4> flintmax
ans =    9.0072e+15
octave-cli:5> tic; sleep (1.5); toc
Elapsed time is 1.5 seconds.


Mike Miller <mtmiller>
Group Member
Mon 28 Oct 2013 01:26:22 PM UTC, original submission:  

The elapsed time as displayed by toc incorrectly reuses the formatting of the previous displayed number:

~:1> exp(9)
ans =  8103.1
~:2> tic;sleep(pi);toc
Elapsed time is 3 seconds.

or even

~:3> tic;sleep(4*pi);toc
Elapsed time is 1e+01 seconds.

Displaying a number with more digits after the decimal point helps:

~:4> exp(10)
ans =  2.2026e+04
~:5> tic;sleep(4*pi);toc
Elapsed time is 12.57 seconds.

Note that the number really has to be displayed:

~:8> exp(9)
ans =  8103.1
~:9> exp(10);
~:10> tic;sleep(4*pi);toc
Elapsed time is 1e+01 seconds.


Workaround: disp(toc)

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #29505:  oct-toc.diff added by mtmiller (667B - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-11-01 jwe StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2013-10-30 mtmiller Attached File- Added oct-toc.diff, #29505
    2013-10-30 jwe Assigned toNone jwe
    2013-10-29 mtmiller StatusNone Confirmed
        Release3.6.2 dev

    Back to the top

    Powered by Savane 3.13-cf05.
    Corresponding source code