diff options
author | pragat-pandya <pragat.pandya@gmail.com> | 2022-02-01 05:59:42 +0530 |
---|---|---|
committer | Hossein <hossein@libreoffice.org> | 2022-02-15 12:17:50 +0100 |
commit | 5f21eaa0e6b689233336cacc949b9a55d545088f (patch) | |
tree | a0f892e0c3a1b738c3e59e934a48b326891714ca /odk/examples/DevelopersGuide/ProfUNO/CppBinding | |
parent | 22d09d65c0e61cac1fa27af6a04a23e16f97c907 (diff) |
tdf#145759 Using M_PI from cmath instead of magic constants.
Replace the instances of Pi's value as magic number by M_PI
Use M_PI_2 and 2_M_PI instead of calculating these values in code.
Use basegfx functions to convert angle units.
Change-Id: I6cca7cc93704a70ccf3a0571a56a789bc9df51ef
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129479
Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Reviewed-by: Hossein <hossein@libreoffice.org>
Tested-by: Jenkins
Diffstat (limited to 'odk/examples/DevelopersGuide/ProfUNO/CppBinding')
-rw-r--r-- | odk/examples/DevelopersGuide/ProfUNO/CppBinding/string_samples.cxx | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/odk/examples/DevelopersGuide/ProfUNO/CppBinding/string_samples.cxx b/odk/examples/DevelopersGuide/ProfUNO/CppBinding/string_samples.cxx index 26162eeb3617..f8bb34f97cd4 100644 --- a/odk/examples/DevelopersGuide/ProfUNO/CppBinding/string_samples.cxx +++ b/odk/examples/DevelopersGuide/ProfUNO/CppBinding/string_samples.cxx @@ -34,7 +34,7 @@ *************************************************************************/ #include <stdio.h> - +#include <cmath> #include <sal/main.h> #include <rtl/ustrbuf.hxx> @@ -49,7 +49,6 @@ SAL_IMPLEMENT_MAIN() // string concatenation sal_Int32 n = 42; - double pi = 3.14159; // give it an initial size, should be a good guess. // stringbuffer extends if necessary @@ -59,7 +58,7 @@ SAL_IMPLEMENT_MAIN() buf.append("pi ( here "); // numbers can be simply appended - buf.append(pi); + buf.append(M_PI); // lets the compiler count the stringlength, so this is more efficient than // the above appendAscii call, where length of the string must be calculated at @@ -67,7 +66,7 @@ SAL_IMPLEMENT_MAIN() buf.append(" ) multiplied with "); buf.append(n); buf.append(" gives "); - buf.append((double)(n * pi)); + buf.append((double)(n * M_PI)); buf.append("."); // now transfer the buffer into the string. |