Skip to content

Commit ad0ef19

Browse files
authored
refactor: add explicit cast in freebsd_pow bit operation (#4960)
Add explicit int32_t cast to clarify the intent of the sign bit extraction operation, preventing potential signed/unsigned conversion warnings on stricter compilers while maintaining the portable implementation.
1 parent 9bdfe8f commit ad0ef19

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • core/shared/platform/common/math

core/shared/platform/common/math/math.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,8 @@ freebsd_pow(double x, double y)
14081408
n = (hx>>31)+1;
14091409
but ANSI C says a right shift of a signed negative quantity is
14101410
implementation defined. */
1411-
n = ((u_int32_t)hx >> 31) - 1;
1411+
/* equal to n = (hx < 0) - 1. But if it works, don't improve it */
1412+
n = (int32_t)((u_int32_t)hx >> 31) - 1;
14121413

14131414
/* (x<0)**(non-int) is NaN */
14141415
if ((n | yisint) == 0)

0 commit comments

Comments
 (0)