Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Unified Diff: fusl/src/complex/csqrtf.c

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: fusl/src/complex/csqrtf.c
diff --git a/fusl/src/complex/csqrtf.c b/fusl/src/complex/csqrtf.c
index ab5102f035b9edc7889ffe3ff24d3b18ffcec50b..7e0955b782c2b4ee1cfa556338e5c71db6622ea3 100644
--- a/fusl/src/complex/csqrtf.c
+++ b/fusl/src/complex/csqrtf.c
@@ -36,47 +36,46 @@
*/
#pragma STDC CX_LIMITED_RANGE ON
-float complex csqrtf(float complex z)
-{
- float a = crealf(z), b = cimagf(z);
- double t;
+float complex csqrtf(float complex z) {
+ float a = crealf(z), b = cimagf(z);
+ double t;
- /* Handle special cases. */
- if (z == 0)
- return CMPLXF(0, b);
- if (isinf(b))
- return CMPLXF(INFINITY, b);
- if (isnan(a)) {
- t = (b - b) / (b - b); /* raise invalid if b is not a NaN */
- return CMPLXF(a, t); /* return NaN + NaN i */
- }
- if (isinf(a)) {
- /*
- * csqrtf(inf + NaN i) = inf + NaN i
- * csqrtf(inf + y i) = inf + 0 i
- * csqrtf(-inf + NaN i) = NaN +- inf i
- * csqrtf(-inf + y i) = 0 + inf i
- */
- if (signbit(a))
- return CMPLXF(fabsf(b - b), copysignf(a, b));
- else
- return CMPLXF(a, copysignf(b - b, b));
- }
- /*
- * The remaining special case (b is NaN) is handled just fine by
- * the normal code path below.
- */
+ /* Handle special cases. */
+ if (z == 0)
+ return CMPLXF(0, b);
+ if (isinf(b))
+ return CMPLXF(INFINITY, b);
+ if (isnan(a)) {
+ t = (b - b) / (b - b); /* raise invalid if b is not a NaN */
+ return CMPLXF(a, t); /* return NaN + NaN i */
+ }
+ if (isinf(a)) {
+ /*
+ * csqrtf(inf + NaN i) = inf + NaN i
+ * csqrtf(inf + y i) = inf + 0 i
+ * csqrtf(-inf + NaN i) = NaN +- inf i
+ * csqrtf(-inf + y i) = 0 + inf i
+ */
+ if (signbit(a))
+ return CMPLXF(fabsf(b - b), copysignf(a, b));
+ else
+ return CMPLXF(a, copysignf(b - b, b));
+ }
+ /*
+ * The remaining special case (b is NaN) is handled just fine by
+ * the normal code path below.
+ */
- /*
- * We compute t in double precision to avoid overflow and to
- * provide correct rounding in nearly all cases.
- * This is Algorithm 312, CACM vol 10, Oct 1967.
- */
- if (a >= 0) {
- t = sqrt((a + hypot(a, b)) * 0.5);
- return CMPLXF(t, b / (2.0 * t));
- } else {
- t = sqrt((-a + hypot(a, b)) * 0.5);
- return CMPLXF(fabsf(b) / (2.0 * t), copysignf(t, b));
- }
+ /*
+ * We compute t in double precision to avoid overflow and to
+ * provide correct rounding in nearly all cases.
+ * This is Algorithm 312, CACM vol 10, Oct 1967.
+ */
+ if (a >= 0) {
+ t = sqrt((a + hypot(a, b)) * 0.5);
+ return CMPLXF(t, b / (2.0 * t));
+ } else {
+ t = sqrt((-a + hypot(a, b)) * 0.5);
+ return CMPLXF(fabsf(b) / (2.0 * t), copysignf(t, b));
+ }
}

Powered by Google App Engine
This is Rietveld 408576698