bugGNU Octave - Bugs: bug #50808, mod(x,y) function incorrect output

 
 

bug #50808: mod(x,y) function incorrect output

Submitted by:  None
Submitted on:  Sat 15 Apr 2017 07:18:15 PM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: InvalidAssigned to: None
Originator Name: Aaron SmithOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 4.0.3
Operating System: Microsoft Windows

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Sat 15 Apr 2017 09:15:29 PM UTC, comment #2:

Yes, 120200318 .^ 2 is larger than flintmax. A double cannot represent this value accurately.

If all of your values are unsigned integers, you should use the uint64 class for your calculations.

Mike Miller <mtmiller>
Project Administrator
Sat 15 Apr 2017 08:07:34 PM UTC, comment #1:

Is your number after you square it and before you do the mod, too big for a double?

I think it is.

Doug Stewart <dastew>
Sat 15 Apr 2017 07:18:15 PM UTC, original submission:

I created a looping script to calculate moduli of a given number raised to a power of 2^x, x = 1,2,3 . . . 27. The script works by squaring the result of the previous modulus (simple number theory concept for congruences used extensively in encryption algorithms, which is the purpose of the script).

On the third iteration of the loop, the output is off by exactly -1; the correct answer should be 28045529. The full output is pasted below, and the script is attached as a file. The one incorrect line throws off all of the results that follow it.

鳴삶Enter value for a: 75634062
ans =
0: 75634062
1: 29168694
2: 120200318
3: 28045528
4: 92729807
5: 53268345
6: 6307007
7: 9600674
8: 45314227
9: 95406753
10: 37769700
11: 52886129
12: 43762381
13: 55560663
14: 132343522
15: 60348756
16: 104657036
17: 31194620
18: 126806889
19: 154670096
20: 145404120
21: 31329860
22: 154886741
23: 70915184
24: 100595978
25: 64254166
26: 114242786
27: 90586916

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #40413:  squaring_script.m added by None (233B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by dastew (Posted a comment)
  • -unavailable- added by None (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 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 15 Apr 2017 09:15:29 PM UTCmtmillerStatusNone=>Invalid
      Open/ClosedOpen=>Closed
    Sat 15 Apr 2017 07:18:15 PM UTCNoneAttached File-=>Added squaring_script.m, #40413

    Back to the top


    Powered by Savane 3.1-cleanup1