src/basics.h

changeset 1178
3a88e7a60b63
parent 1177
8661b9237ed5
child 1181
ca6d0ef9aadb
--- a/src/basics.h	Fri Mar 03 00:35:43 2017 +0200
+++ b/src/basics.h	Fri Mar 03 23:08:04 2017 +0200
@@ -315,3 +315,15 @@
 {
 	return ring.size();
 }
+
+/*
+ * Extracts the sign of x.
+ */
+template<typename T>
+T sign(T x)
+{
+	if (isZero(x))
+		return {};
+	else
+		return x / qAbs(x);
+}

mercurial