diff --git a/lib/modules/Int.pmod b/lib/modules/Int.pmod new file mode 100644 index 0000000000000000000000000000000000000000..69991bf0c2a5a81f266dd518a3e1d35878ca20f7 --- /dev/null +++ b/lib/modules/Int.pmod @@ -0,0 +1,9 @@ +#pike __REAL_VERSION__ +#pragma strict_type + +//! Returns the parity of the integer @[value]. If the +//! parity is odd 1 is returned. If it is even 0 is +//! returned. +int(0..1) parity(int(0..) value) { + return String.count(sprintf("%b",value),"1")&1; +}