Bug 32862 - Improve precision of function MOD() for big numbers (7^19 mod 13 is 6 not 7)
Summary: Improve precision of function MOD() for big numbers (7^19 mod 13 is 6 not 7)
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: x86 (IA32) Linux (All)
: low enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 32866
  Show dependency treegraph
 
Reported: 2011-01-05 15:20 UTC by Tim Baumann
Modified: 2011-06-18 15:19 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
The document I used in the presentation (24.22 KB, application/vnd.oasis.opendocument.spreadsheet)
2011-01-05 15:20 UTC, Tim Baumann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Baumann 2011-01-05 15:20:27 UTC
Created attachment 41693 [details]
The document I used in the presentation

I recently gave a presentation about asymmetric cryptography and I used a spreadsheet to show the graph of the function 7^x mod 13. Unfortunately, as one person in the audience noticed, there was a mistake in the data. The value of the field C20 (=> x=19) in the document I attached must be 6 not 7.
Comment 1 Regina Henschel 2011-01-05 17:15:35 UTC
Calc uses number type "double" and 7^19 is to large to be represented in 53 Bits. So the needed figures don't exist. I don't know whether Calc should produce an error, if the second argument of MOD is integral and the first argument is to large. (Teaching cryptography to pupils I introduce "PowerMod" then.)

For your spreadsheet the solution is to calculate it iterative.
Start with 1 in cell C1.
In cell C2 use the formula =MOD(C1*7;13)
In cell C3 use the formula =MOD(C2*7;13) and so on with drag fill.
Comment 2 Rainer Bielefeld Retired 2011-01-05 22:05:03 UTC
.
Comment 3 Tim Baumann 2011-01-07 08:09:12 UTC
Thanks for your help, but it's already too late. I didn't expect such an error because I used integers and some programming languages such as python have no problem with very big integers. In my opinion, there should be a sign for the user if a number gets too large (is this possible?).

(In reply to comment #1)
> Calc uses number type "double" and 7^19 is to large to be represented in 53
> Bits. So the needed figures don't exist. I don't know whether Calc should
> produce an error, if the second argument of MOD is integral and the first
> argument is to large. (Teaching cryptography to pupils I introduce "PowerMod"
> then.)
> 
> For your spreadsheet the solution is to calculate it iterative.
> Start with 1 in cell C1.
> In cell C2 use the formula =MOD(C1*7;13)
> In cell C3 use the formula =MOD(C2*7;13) and so on with drag fill.
Comment 4 LeMoyne Castle 2011-06-15 11:53:00 UTC
Changed to low-enhancement to match 32834 (related by 32866) 
Low because happens to small set of users in integer functions applied to large values. Issue is very real for users requiring extended precision - in this case a mathematically sound workaround exists.  Integer ops on very large #s must eventually run afoul of the underlying implementation's precision limit.  
It is an Enhancement to consider either a different implementation or different action (err past limits) for integer operators/functions on very large or very tiny numbers in either Calc or BASIC.
Comment 5 wope 2011-06-18 15:19:47 UTC
for large numbers crunching, you must use mathematica, matlab or similar programs.
Calc (and Excel) are wrong decissions.