Bug 105931 - Add function to Calc that rounds to significant digits
Summary: Add function to Calc that rounds to significant digits
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
(earliest affected)
Hardware: All All
: medium enhancement
Assignee: Winfried Donkers
QA Contact:
Whiteboard: target:5.4.0
Depends on:
Reported: 2017-02-11 10:22 UTC by Winfried Donkers
Modified: 2017-03-04 08:55 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Note You need to log in before you can comment on or make changes to this bug.
Description Winfried Donkers 2017-02-11 10:22:33 UTC
Calc currently does not have a function that rounds a value to a determined number of significant digits.
Rounding to significant digits is useful for scientific and engineering users as well as for unit tests of functions that return numeric results.

Steps to Reproduce:

Actual Results:  

Expected Results:

Reproducible: Always

User Profile Reset: No

Additional Info:

User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0
Comment 1 Winfried Donkers 2017-02-11 10:40:02 UTC
Specification for function SIGDIGITS:

Summary: Rounds the value X to the number of significant digits specified by Digits.

Syntax: ROUND( Number X ; Integer Digits )

Returns: Number

Constraints: 0 < Digits

round( X * 10^−n) * 10^n 
with n = floor(log10(x)) + 1 − Digits.
Comment 2 Commit Notification 2017-02-20 17:05:13 UTC
Winfried Donkers committed a patch related to this issue.
It has been pushed to "master":


tdf#105931 Add function ROUNDSIG to Calc.

It will be available in 5.4.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:

Affected users are encouraged to test the fix and report feedback.
Comment 3 Winfried Donkers 2017-02-28 14:43:16 UTC
An unexpected result comes from
Most of the times, the result is -1.3862065601674 (incorrect).
Sometimes it is -1.3862065601673 (correct).
Other ROUNDSIG instances with T.INV and 14 digits don't show this behaviour.

=ROUNDSIG(T.INV(0.15,2),14) consequently returns -1.38620656016734 (correct).

I do not know yet if this is caused by ROUNDSIG() or by something else.
Comment 4 Winfried Donkers 2017-03-04 08:55:03 UTC
(In reply to Winfried Donkers from comment #3)
> =ROUNDSIG(T.INV(0.15,2),14) consequently returns -1.38620656016734 (correct).

Oops, this should be
=ROUNDSIG(T.INV(0.15,2),15) consequently returns -1.38620656016734 (correct).