Bug 105931 - Add function to Calc that rounds to significant digits
Summary: Add function to Calc that rounds to significant digits
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
5.4.0.0.alpha0+
Hardware: All All
: medium enhancement
Assignee: Winfried Donkers
QA Contact:
URL:
Whiteboard: target:5.4.0
Keywords:
Depends on:
Blocks:
 
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:


Attachments

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
Description:
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:
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

Semantics: 
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":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=3ee1c41ac72aaae9f364708b1c4df58d7643a341

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:
http://wiki.documentfoundation.org/Testing_Daily_Builds

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
=ROUNDSIG(T.INV(0.15,2),14)
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).