editeng/source/misc/txtrange.cxx |    7 ++++---
 include/basegfx/color/bcolor.hxx |    2 +-
 vcl/unx/generic/app/saldisp.cxx  |    5 +----
 3 files changed, 6 insertions(+), 8 deletions(-)

New commits:
commit c6755955aeaddb14bd3ad231f78cda47a0a5aeaa
Author:     buldi <dobrakowskira...@gmail.com>
AuthorDate: Sun Apr 2 18:16:10 2023 +0200
Commit:     Hossein <hoss...@libreoffice.org>
CommitDate: Mon Apr 24 00:52:19 2023 +0200

    tdf#147906 Use std::hypot for Pythagorean addition
    
    Change-Id: I47611e1bffed814294bd2c7b23b26e1878151464
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149939
    Tested-by: Jenkins
    Reviewed-by: Hossein <hoss...@libreoffice.org>

diff --git a/editeng/source/misc/txtrange.cxx b/editeng/source/misc/txtrange.cxx
index 6374747be3c9..2f02a1150f91 100644
--- a/editeng/source/misc/txtrange.cxx
+++ b/editeng/source/misc/txtrange.cxx
@@ -192,11 +192,12 @@ tools::Long SvxBoundArgs::CalcMax( const Point& rPt1, 
const Point& rPt2,
     }
     else
         nB = nStart;
-    nB *= nB;
-    nB += nDa * nDa;
-    nB = sqrt( nB );
+
+    nB = std::hypot(nB, nDa);
+
     if (nB == 0) // avoid div / 0
         return 0;
+
     nB = nRange + nDa * ( nFarRange - nRange ) / nB;
 
     bool bNote;
diff --git a/include/basegfx/color/bcolor.hxx b/include/basegfx/color/bcolor.hxx
index d8788b1cfef1..de3452fad128 100644
--- a/include/basegfx/color/bcolor.hxx
+++ b/include/basegfx/color/bcolor.hxx
@@ -136,7 +136,7 @@ namespace basegfx
             const double fDistG(getDistanceGreen(rColor));
             const double fDistB(getDistanceBlue(rColor));
 
-            return sqrt(fDistR * fDistR + fDistG * fDistG + fDistB * fDistB);
+            return std::hypot(fDistR, fDistG, fDistB);
         }
 
         double getMaximumDistance(const BColor& rColor) const
diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx
index 6d7737cb3224..3e2e58d9c319 100644
--- a/vcl/unx/generic/app/saldisp.cxx
+++ b/vcl/unx/generic/app/saldisp.cxx
@@ -80,9 +80,6 @@ static const char *KeyStr( KeySym n ) { return Null( 
XKeysymToString( n ) ); }
 
 static const char *GetAtomName( Display *d, Atom a )
 { return Null( XGetAtomName( d, a ) ); }
-
-static double Hypothenuse( tools::Long w, tools::Long h )
-{ return sqrt( static_cast<double>((w*w)+(h*h)) ); }
 #endif
 
 static int ColorDiff( int r, int g, int b )
@@ -2207,7 +2204,7 @@ void SalDisplay::PrintInfo() const
     SAL_INFO( "vcl", "Screen" );
     SAL_INFO( "vcl", "\tResolution/Size   \t" << aResolution_.A() << "*" << 
aResolution_.B()
             << " " << 
m_aScreens[m_nXDefaultScreen.getXScreen()].m_aSize.Width() << "*" << 
m_aScreens[m_nXDefaultScreen.getXScreen()].m_aSize.Height()
-            << " " << (Hypothenuse( DisplayWidthMM ( pDisp_, 
m_nXDefaultScreen.getXScreen() ),
+            << " " << (std::hypot( DisplayWidthMM ( pDisp_, 
m_nXDefaultScreen.getXScreen() ),
                           DisplayHeightMM( pDisp_, 
m_nXDefaultScreen.getXScreen() ) ) / 25.4 ) << "\"" );
     SAL_INFO( "vcl", "\tBlack&White       \t" << 
GetColormap(m_nXDefaultScreen).GetBlackPixel() << " "
             << GetColormap(m_nXDefaultScreen).GetWhitePixel() );

Reply via email to