Bug 170299 - Calc shows 0 instead of error when number overflows
Summary: Calc shows 0 instead of error when number overflows
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
25.8.4.2 release
Hardware: ARM macOS (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-01-12 00:59 UTC by tariq.rashid50
Modified: 2026-01-13 10:59 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
ODS file with error (13.44 KB, application/vnd.oasis.opendocument.spreadsheet)
2026-01-12 01:00 UTC, tariq.rashid50
Details
excel file showing proper error handling (9.97 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2026-01-12 01:00 UTC, tariq.rashid50
Details
screenshot comparing Calc and Excel (790.91 KB, image/png)
2026-01-12 01:00 UTC, tariq.rashid50
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tariq.rashid50 2026-01-12 00:59:42 UTC
Description:
When a call calculates a number that is too large, it shows and uses 0 instead of reporting and error.

I have attached a screenshot comparing this with the correct behaviour in MS Excel.

I have also attached the Calc ODS and Excel files.

The formula is x^((p-1)!) mod p ... where x^((p-1)!) grows too large when x=5 and p=5, that is 5^(24).



Steps to Reproduce:
See attached spreadsheets and screenshot.

Actual Results:
The apparent result of the calculation is 0, and the subsequent calculations are false.


Expected Results:

Instead of 0, an error should be reported.


Reproducible: Always


User Profile Reset: No

Additional Info:
We accept that accuracy is limited by floating point representation and calculations.

But this is different.

This is falsely assigning 0 to an error.
Comment 1 tariq.rashid50 2026-01-12 01:00:06 UTC
Created attachment 205009 [details]
ODS file with error
Comment 2 tariq.rashid50 2026-01-12 01:00:23 UTC
Created attachment 205010 [details]
excel file showing proper error handling
Comment 3 tariq.rashid50 2026-01-12 01:00:46 UTC
Created attachment 205011 [details]
screenshot comparing Calc and Excel
Comment 4 Regina Henschel 2026-01-12 21:38:42 UTC
Example: 6^24 results in 4738381338321620000 instead of 4738381338321616896. It is rounded to 15 significant digests. And the rounded value mod 5 is zero. 

LibreOffice has no special integer arithmetic but uses the precision of "double" data type. And from its 52 significant bits you can get only about 15 significant digits in a decimal representation of the number.

Thus it is not an "overflow" problem but a problem of precision. LibreOffice does not consider this as bug. See
https://help.libreoffice.org/26.8/en-US/text/scalc/01/calculation_accuracy.html

The same precision problem occurs when calculating MOD(1.5^n; 5). It is only accurate for n=1,2,3,...,14. For integers greater than 14, Excel does not display an error message in this case. This is inconsistent in Excel.
Comment 5 tariq.rashid50 2026-01-13 10:59:58 UTC
Thanks Regina - I can see now this is due to accuracy and not overflow. 

Ideally the user would be informed but I suspect that is not easy to do, as it might are with a true overflow.

Thanks