@@ -5,7 +5,7 @@ import { SD59x18 } from "./ValueType.sol";
5
5
import { uUNIT } from "./Constants.sol " ;
6
6
7
7
// Pi / 2;
8
- int256 constant uPI2 = 1_570796326794896619 ;
8
+ int256 constant uPI2 = 1_570796326794896619 ;
9
9
10
10
// Cordic renormalisation factor
11
11
int256 constant K = 607252935008881256 ;
@@ -75,11 +75,11 @@ int256 constant ATAN31 = 465661287;
75
75
76
76
function cordic_step (int256 x , int256 y , int256 z , int256 f , int256 t ) pure returns (int256 x2 , int256 y2 , int256 z2 , int256 f2 ) {
77
77
assembly {
78
- let delta := sub (mul (sgt (z, 0 ), 2 ), 1 ) // z > 0 ? 1 : -1
78
+ let delta := sub (mul (sgt (z, 0 ), 2 ), 1 ) // z > 0 ? 1 : -1
79
79
x2 := sub (x, sdiv (mul (mul (delta, y), f), uUNIT)) // x - delta * y * f / uUNIT
80
80
y2 := add (y, sdiv (mul (mul (delta, x), f), uUNIT)) // y + delta * x * f / uUNIT
81
- z2 := sub (z, mul (delta, t)) // z + delta * t
82
- f2 := shr (1 , f) // f / 2
81
+ z2 := sub (z, mul (delta, t)) // z + delta * t
82
+ f2 := shr (1 , f) // f / 2
83
83
}
84
84
}
85
85
@@ -124,10 +124,7 @@ function cordic(int256 t) pure returns (int256, int256) {
124
124
(x, y, z, f) = cordic_step (x, y, z, f, ATAN31);
125
125
x = x * K / uUNIT;
126
126
y = y * K / uUNIT;
127
- return (q == 0 ) ? (x, y) :
128
- (q == 1 ) ? (- y, x) :
129
- (q == 2 ) ? (- x, - y) :
130
- (y, - x);
127
+ return (q == 0 ) ? (x, y) : (q == 1 ) ? (- y, x) : (q == 2 ) ? (- x, - y) : (y, - x);
131
128
}
132
129
}
133
130
0 commit comments