summaryrefslogtreecommitdiff
path: root/sal/rtl/math.cxx
AgeCommit message (Collapse)Author
2018-03-02Disable -fsanitize=float-divide-by-zero in rtl_math_atanhStephan Bergmann
...which relies on division by zero producing inf, for atanh(1) = inf. (As tested by CppunitTest_sal_rtl.) Change-Id: I0e5de8850ab4cbd05f83027c1eb548e2e0c9a9b2 Reviewed-on: https://gerrit.libreoffice.org/50613 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-01-29Translate German variable nameJohnny_M
Korr -> Corr in math Change-Id: I33c3d0fa62aa0c4b6fd418ba2e49b90b019b8714 Reviewed-on: https://gerrit.libreoffice.org/48782 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
2018-01-19Remove include of config_global.h from sal/config.hStephan Bergmann
(where it is not actually needed), and instead include it where needed Change-Id: I107f8d4002d3001393b89834dd30a30b0c53a792 Reviewed-on: https://gerrit.libreoffice.org/48152 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Stephan Bergmann <sbergman@redhat.com>
2018-01-18Include android/compatibility.hxx from ubiquitous sal/config.hStephan Bergmann
...instead of having to add it to more and more individual .cxx files, as the need arises. Change-Id: If1e893c79abf1c1bb7fb7b89dcb9bd423a7f1b94 Reviewed-on: https://gerrit.libreoffice.org/48108 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Stephan Bergmann <sbergman@redhat.com>
2018-01-16sal: try to fix Android build, no std::roundMichael Stahl
Change-Id: I58bc7c9099cd2a3a90f92efbd179d0f3abce02a6
2018-01-16tdf#96821 fix corner cases for Calc function ROUND.Winfried Donkers
For very large integer numbers, e.g. 2^52+1, ROUND produced incorrect results because rtl::math::round uses floor( number + 0.5 + small_correction_value ), which reduces the maximum possible mantissa resolution.a Correction of several unit test documents (Calc functions) with rounding errors that only became apparent with this fix. Change-Id: I1769c9939a3d6118d3bfbfdf8e41dd4619997232 Reviewed-on: https://gerrit.libreoffice.org/47179 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com>
2018-01-15convert a<b?a:b to std::min(a,b)Noel Grandin
with something like git grep -nP '(.*)\s*<\s*(.*)\s*\?\s*\g1\s*:\s*\g2' -- *.?xx Change-Id: Id5078b35961847feb78a66204fdb7598ee63fd23 Note: we also convert a>b?b:a Reviewed-on: https://gerrit.libreoffice.org/47736 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-01-11convert (a>b?a:b) to std::max(a,b)Noel Grandin
with something like: git grep -nP '(.*)\s*>\s*(.*)\s*\?\s*\g1\s*:\s*\g2' Change-Id: I60b9a3a2a09162bc0de4c13fdde2c209696e5413 Reviewed-on: https://gerrit.libreoffice.org/47602 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-01-04ofz#4886 Integer-overflowCaolán McNamara
sal/rtl/math.cxx:1106:29: runtime error: signed integer overflow: 15 - -2147483648 cannot be represented in type 'int' Change-Id: Ia81eca9da1fe7cc1a5c5319742b32bd742fb817e Reviewed-on: https://gerrit.libreoffice.org/47329 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-11-23loplugin:simplifybool can't invert conditions involving float typesNoel Grandin
so revert some of the changes from commit 7a1c21e53fc4733a4bb52282ce0098fcc085ab0e loplugin:simplifybool for negation of comparison operator Change-Id: I937d575b86c1e418805d399b0dc16ae91876b4fe Reviewed-on: https://gerrit.libreoffice.org/45130 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-11-23loplugin:simplifybool for negation of comparison operatorNoel Grandin
Change-Id: Ie56daf560185274754afbc7a09c432b5c2793791 Reviewed-on: https://gerrit.libreoffice.org/45068 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-11-22ofz#4366 Divide-by-zeroStephan Bergmann
Change-Id: I3d0eb3bb6a69d09e71ce8bf91051f66e204eb0df Reviewed-on: https://gerrit.libreoffice.org/45098 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins <ci@libreoffice.org>
2017-10-25ofz#3789 Integer-overflowCaolán McNamara
with input 69e9223372036854775807 Change-Id: Iaf5a85170d144be2db5604340d784a8982754e08 Reviewed-on: https://gerrit.libreoffice.org/43815 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2017-10-23loplugin:includeform: salStephan Bergmann
Change-Id: I539ca8b9dee5edc5fc2282a2b9b0ffd78bad8b11
2017-10-20Comment some values that 16 doesn't workEike Rathke
One of them was removed with e6611cc2ef5960e9f32c56da44fafd02446f53e6, reintroduce to prevent running into a dead end again. 16 or 17 digits will need some different approach. Change-Id: Iec213ed857121e323e13ee83763c51fa563c794f
2017-10-19tdf#113211: fix calculations with big integersMike Kaganski
... and munbers with few fractional bits Change-Id: I86c3e8021e803fed498fae768ded9c9e5337c8bd Reviewed-on: https://gerrit.libreoffice.org/43477 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com>
2017-07-23rtl: cleanup equality conditions in math.cxxChris Sherlock
Change-Id: I13d898479d883f7905d834c82dc778a9e4078375
2017-06-09clang-tidy readability-non-const-parameterNoel Grandin
Change-Id: I7b2680898dbfc49185fb949349d81f4ac615a470 Reviewed-on: https://gerrit.libreoffice.org/38593 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-04-12clang-tidy: readability-else-after-returnNoel Grandin
run it against sal,cppu,cppuhelper I had to run this multiple times to catch all the cases in each module, and it requires some hand-tweaking of the resulting output - clang-tidy is not very good about cleaning up trailing spaces, and aligning things nicely. Change-Id: I00336345f5f036e12422b98d66526509380c497a Reviewed-on: https://gerrit.libreoffice.org/36194 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-03-22Prevent calls to rtl/character.hxx functions with (signed) char argumentsStephan Bergmann
...that would implicitly be sign extended (for plain char only if it is signed), so non-ASCII char values would trigger the isUnicodeCodePoint assert. Change-Id: Iaf8024ad509e64525558e882fe3fd078cfb4ea91 Reviewed-on: https://gerrit.libreoffice.org/35523 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-03-03Remove redundant 'inline' keywordStephan Bergmann
...from function definitions occurring within class definitions. Done with a rewriting Clang plugin (to be pushed later). Change-Id: I9c6f2818a57ccdb361548895a7743107cbacdff8 Reviewed-on: https://gerrit.libreoffice.org/34874 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-02-08Solaris C++ 5.2 compiler is no longer relevantStephan Bergmann
Change-Id: I520a58438e156661d3e01a899e97ee33d9f19102
2016-10-13approxEqual: check isFinite()Eike Rathke
Necessary as all comparisons involving a Nan evaluate to false and the assert() in isRepresentableInteger() was hit by crash test documents where approxEqual() was called with a least one Nan. Change-Id: I9e8f41c36c0cf14cabf47c3df773c601d32682d6
2016-10-10Handle loplugin:fpcomparison false positives by whitelistStephan Bergmann
Change-Id: I58e2beb0695a27922856bd8f8988d9e4508aceb6
2016-10-04isRepresentableInteger: assert(fAbsValue >= 0.0)Eike Rathke
Change-Id: Idf140b312617e2a3a739cb5571d1b29ef700315c
2016-10-01let approxEqual() not scale too early for large representable integer valuesEike Rathke
And since this is now too much code for inline move implementation to math.cxx Which again made it necessary to give libreofficekit lokdocview.cxx its own implementation that doesn't even claim to build against sal ... Change-Id: I0f80be9d9172ee20693b9babde715206f2c3d8c1 Reviewed-on: https://gerrit.libreoffice.org/29428 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins <ci@libreoffice.org>
2016-09-26sal: Mac OS X 10.8 fails test_log1pMichael Stahl
... because its libc log1p() does not return -0.0 unmodified but as +0.0 Change-Id: Ib3fcd005a9876e0e74775bf4f826a887cdd29279 Reviewed-on: https://gerrit.libreoffice.org/29237 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com>
2016-06-27stringToDouble() do not parse separator without digit as 0.0Eike Rathke
Occurred in CSV import without "detect special numbers" activated for data like ,., where the . dot resulted in a numeric cell value 0 Change-Id: Ie715d7a8ed02196b59968a92919ad286b3bedf64
2016-06-27stringToDouble() fix broken reverse logic for NaN and INFEike Rathke
... and do not test up to three characters if the string is shorter.. Change-Id: I52b74cbde10c14c991cc8c68760c87c1e08ab7e4
2016-01-14use ::std::swap() to reverse bufferEike Rathke
Change-Id: I7e18e57636416f0a3ed96c2fa3adc004fb3ba013
2016-01-14use getN10Exp(x) instead of pow(10.0,x)Eike Rathke
Change-Id: Ib7e49126cbffc510fa941c25a8d57222bad51c46
2016-01-14handle negative decimal places for rounding, tdf#96918 relatedEike Rathke
Change-Id: Ifa423eabc64ead519c4f4a3370a06e88ea5c7466
2016-01-13sal: as always C++ is too stupid to deduce parameter types of minMichael Stahl
Change-Id: Ib00f29a6024e22c65a30bf4a45332e550994f03f
2016-01-13tdf#96918 display accurate integer double values up to (2^53)-1Eike Rathke
Change-Id: I42001583c72bc3faab94489a4eabfa183cab5ae2
2015-12-10More loplugin:nullptr automatic rewrite (within templates)Stephan Bergmann
Change-Id: I9bc06cfb5eeb38fd7ae7fb25f876ea9f96e4a65a
2015-11-10loplugin:nullptr (automatic rewrite)Stephan Bergmann
Change-Id: I1bc6c87fcd6e5e96362623be94c59be216a3b2b8
2015-10-26Revert "see if including cmath instead of math.h satisfies Android-ARM"Eike Rathke
This reverts commit 6f9e272da724237e52f2f93f235ae78c5344a21a. A f*cking mess. See 1cdf6ade0eeac9515ed88ae0cd802fe119dd4249 Change-Id: Ia66edb96c9c34742300e882c2796870bfd9919d1
2015-10-26see if including cmath instead of math.h satisfies Android-ARMEike Rathke
Change-Id: Ie96f459dfe6d515ac92d89fcf6e6393a35bb97ac
2015-10-26Revert "attempted fix for android build"Stephan Bergmann
This reverts commit c3acead32e1d844b81e3e90c72549281d4bc73a2, now that cc906ec47eaaad247e8fbed5c9e6f3604a8b64c7 "The Android NDK for some reason don't have these math functions in std::" uses all the declarations from <math.h> instead of <cmath>.
2015-10-26Revert "sal: fix Android build"Miklos Vajna
This workaround is not needed after cc906ec47eaaad247e8fbed5c9e6f3604a8b64c7. This reverts commit d366d680cb62a2c5a7246e7290ef74c7e52eb04f.
2015-10-26sal: fix Android buildMiklos Vajna
Similar to 9a93277b869caca4db054385db59fc7b7d541570 (vcl: fix Android build, 2015-03-06), where the Android has a broken C++ library, having some functions in the global namespace instead of the std one. Work around the problem by using the std namespace till it gets fixed on the Android side. Change-Id: I3d423f42b4e8e325beb3661c1780378e5edf962d
2015-10-26The Android NDK for some reason don't have these math functions in std::Tor Lillqvist
Not even if one includes <cmath> instead of <math.h>. So just use the C functions then. Change-Id: Ic8499bc7bcd5c84b6e52e1d5dc799f9f058db816
2015-10-26attempted fix for android buildNoel Grandin
Change-Id: I47e5e3ebbbf55ae1fbbf2df85f9efbdd8bca1322
2015-10-25replace implementation of rtl_math_expm1() and rtl_math_log1p()Eike Rathke
... with ::std::expm1() and ::std::log1p() of C++11 Change-Id: I0d119958152ea372c136d28705686b44b39015bf Reviewed-on: https://gerrit.libreoffice.org/19588 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
2015-10-24replace implementation of rtl_math_erf() and rtl_math_erfc()Eike Rathke
... with ::std::erf() and ::std::erfc() of C++11 Change-Id: I8ccc86ec4d6d71a92409770fc119f72e7084073a Reviewed-on: https://gerrit.libreoffice.org/19583 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
2015-10-24implement Inf and NaN handling for rtl_math_expm1() and rtl_math_log1p()Eike Rathke
Change-Id: Ie424a6f038107ef8b574d0422efaf49b441c110f
2015-10-24implement proper Inf and NaN handling in rtl_math_erf() and rtl_math_erfc()Eike Rathke
Change-Id: Ib96d7123a3c483e9a1c78666bf042396510d733f
2015-10-24prevent endless recursion through rtl_math_erf* for Inf or NaNEike Rathke
Change-Id: If6eb273bc4d76f85da0844caea4bd697c6263013
2015-03-31Reduce to static_cast any reinterpret_cast from void pointersStephan Bergmann
Change-Id: Ic03728b2824eb59b9b6351a88ec355bfb93154cb
2015-02-23tdf#88835 Calc: General format: 2 digits in exponentLaurent Balland-Poirier
Create 4 new formats enums rtl_math_StringFormat: rtl_math_StringFormat_E1, rtl_math_StringFormat_E2, rtl_math_StringFormat_G1, rtl_math_StringFormat_G2 to 1 or 2 digits in exponent for scientific notation. Set General format to use rtl_math_StringFormat_E2. Set trendline equation in status bar to use rtl_math_StringFormat_E1 Change-Id: I41466a6d4ba808ba5b9b38ba252b37c6b4560f12 Reviewed-on: https://gerrit.libreoffice.org/14562 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>