[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] master babe6af16: * src/base/ftcalc.c /* FT_SqrtFixed */: Fi
From: |
Werner Lemberg |
Subject: |
[freetype2] master babe6af16: * src/base/ftcalc.c /* FT_SqrtFixed */: Fix defunct overflow. |
Date: |
Mon, 18 Sep 2023 11:01:41 -0400 (EDT) |
branch: master
commit babe6af16740f3fa3c19ef4b689f29d574c5fbc8
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>
* src/base/ftcalc.c /* FT_SqrtFixed */: Fix defunct overflow.
---
src/base/ftcalc.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c
index ba4d5e3fd..0b915992a 100644
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -917,17 +917,18 @@
/* documentation is in ftcalc.h */
- /* Algorithm and code by Christophe Meessen (1993). */
+ /* Algorithm and code by Christophe Meessen (1993) */
+ /* with overflow fixed. */
FT_BASE_DEF( FT_UInt32 )
- FT_SqrtFixed( FT_UInt32 r )
+ FT_SqrtFixed( FT_UInt32 v )
{
- FT_UInt32 t, q, b;
+ FT_UInt32 r = v >> 1;
+ FT_UInt32 q = ( v & 1 ) << 15;
+ FT_UInt32 b = 0x20000000;
+ FT_UInt32 t;
- q = 0;
-
- b = 0x40000000;
- while ( b > 0x40 )
+ do
{
t = q + b;
if ( r >= t )
@@ -938,8 +939,9 @@
r <<= 1;
b >>= 1;
}
+ while ( b > 0x20 );
- return q >> 8;
+ return q >> 7;
}
#endif /* 0 */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] master babe6af16: * src/base/ftcalc.c /* FT_SqrtFixed */: Fix defunct overflow.,
Werner Lemberg <=