Module Name:    src
Committed By:   maya
Date:           Sat Dec 31 22:54:56 UTC 2016

Modified Files:
        src/lib/libm/complex: csqrtf.c

Log Message:
similar to csqrt, spare ourselves a fabsf call. we already check sign
later on, use this to our advantage.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libm/complex/csqrtf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libm/complex/csqrtf.c
diff -u src/lib/libm/complex/csqrtf.c:1.2 src/lib/libm/complex/csqrtf.c:1.3
--- src/lib/libm/complex/csqrtf.c:1.2	Sat Dec 31 20:01:15 2016
+++ src/lib/libm/complex/csqrtf.c	Sat Dec 31 22:54:56 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: csqrtf.c,v 1.2 2016/12/31 20:01:15 maya Exp $ */
+/* $NetBSD: csqrtf.c,v 1.3 2016/12/31 22:54:56 maya Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -55,12 +55,13 @@ csqrtf(float complex z)
 	}
 
 	if (x == 0.0f) {
-		r = fabsf(y);
-		r = sqrtf(0.5f * r);
-		if (y > 0)
+		if (y > 0) {
+			r = sqrtf(0.5f * y);
 			w = r + r * I;
-		else
+		} else {
+			r = sqrtf(-0.5f * y);
 			w = r - r * I;
+		}
 		return w;
 	}
 

Reply via email to