bugGNU Octave - Bugs: bug #29347, factor works only for integers...

 
 

bug #29347: factor works only for integers <2^54 and only for doubles

Submitted by:  None
Submitted on:  Fri 26 Mar 2010 12:20:19 PM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: NoneAssigned to: Jaroslav Hajek <highegg>
Originator Name: Erich DolejsiOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 3.3.50
Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Wed 31 Mar 2010 06:05:18 AM UTC, comment #1:

Fixed in development sources, I use rem() which now maps to C's % for integers, so factoring things like uint64(2^56) + 1 now gives the correct answer.
I should, however, add, that the algorithm used by factor() is quite primitive, based on table of primes up to sqrt(n) and so factoring 2^63 is still not typically possible because it won't fit into memory.

Jaroslav Hajek <highegg>In charge of this item.
Fri 26 Mar 2010 12:20:19 PM UTC, original submission:

factor does not work for integer datatypes because of
q = n ./ p;
p = p (q == fix (q));
thats around line 69
it's works when
q = mod(n,p);
p = p (q==0);
is used instead.

But because octave uses in reality double instead of uint64
one cannot factor large uint64 integers.

if(2^54<n)
error('to big you use inexact integers even when you use uint64')
endif
I think that's the border for int in double 2^54.

Several other functions dosen't work because of rounding
uint64(7)/uint64(8) = 1
this also causes problems.

It's worth to check integer arithmetic over 2^54 in uint64 or
int64 because of limitations of double.

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by highegg (Posted a comment)
  •  

    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 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 31 Mar 2010 06:05:54 AM UTChigheggCategoryNone=>Interpreter
      Assigned toNone=>highegg
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1