bugGNU Octave - Bugs: bug #37880, Make factor to not show wrong...

 
 

bug #37880: Make factor to not show wrong answers for large numbers

Submitted by:  Doug Stewart <dastew>
Submitted on:  Fri Dec 7 15:13:16 2012  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Inaccurate Result
Status: FixedAssigned to: None
Originator Name: Doug StewartOpen/Closed: Closed
Release: devOperating System: Any

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Mon Oct 21 22:19:12 2013, comment #3:

I modified and applied your patch here (http://hg.savannah.gnu.org/hgweb/octave/rev/e48f5a52e838). This will be a part of the 3.8 release due out in a few weeks.

It seems like we could actually do better if we switched to calculating with int64, instead of double. I tested this idea and it works for numbers above bitmax(), but there is a problem with the prod() function in that it only works in double precision. If we fix that to be able to use the class of the inputs to prod() then this restriction can be lifted.

Rik <rik5>
Project Administrator
Mon Sep 30 15:13:39 2013, comment #2:

See bug #37830

octave-3.2.4:1> bitmax
ans = 9.0072e+15
octave-3.2.4:2> factor(bitmax)
ans =

6361 69431 20394401

octave-3.2.4:3> prod(ans)
ans = 9.0072e+15
octave-3.2.4:4> factor(bitmax+1)
ans =

Columns 1 through 20:

2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Columns 21 through 40:

2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
Columns 41 through 53:

2 2 2 2 2 2 2 2 2 2 2 2 2

octave-3.2.4:5> prod(ans)
ans = 9.0072e+15

octave-3.2.4:6> factor(bitmax+2)
ans =

Columns 1 through 20:

2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Columns 21 through 40:

2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Columns 41 through 53:

2 2 2 2 2 2 2 2 2 2 2 2 2

octave-3.2.4:7> prod(ans)
ans = 9.0072e+15

octave-3.2.4:6> factor(bitmax+2)
ans =

Columns 1 through 20:

2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Columns 21 through 40:

2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Columns 41 through 53:

2 2 2 2 2 2 2 2 2 2 2 2 2

octave-3.2.4:7> prod(ans)
ans = 9.0072e+15

octave-3.2.4:8> factor(bitmax+200)
ans =

2.0000e+00 2.0000e+00 2.0000e+00 8.9000e+01 6.9490e+03 1.8205e+09

octave-3.2.4:9> prod(ans)
ans = 9.0072e+15
octave-3.2.4:10> factor(bitmax+20011)
ans =

2 71 107 919 645063007

octave-3.2.4:11> prod(ans)
ans = 9.0072e+15

I don't know what matlab does.

I understand that the user should not ask such a question, but they do.
So what should we do when they do ask?

I think we should worn them, and this is what the patch does.

Doug

Doug Stewart <dastew>
Mon Sep 30 01:34:19 2013, comment #1:

Can you paste an example with input and output parameters of what problem this patch is addressing? And what does Matlab do with the same example?

Mike Miller <mtmiller>
Project Administrator
Fri Dec 7 15:13:16 2012, original submission:

Patch is attached.

Doug

Doug Stewart <dastew>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #27052:  15744.patch added by dastew (1kB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Updated the item)
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by dastew (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon Oct 21 22:19:12 2013rik5StatusPatch Submitted=>Fixed
      Open/ClosedOpen=>Closed
    Thu Oct 17 21:20:08 2013rik5StatusNeed Info=>Patch Submitted
    Mon Sep 30 01:34:19 2013mtmillerCategoryNone=>Octave Function
      StatusNone=>Need Info
    Fri Dec 7 15:13:16 2012dastewAttached File-=>Added 15744.patch, #27052

    Back to the top


    Powered by Savane 3.1-cleanup