From b25fa64539df938bc922c71a6b3fff1de07464bc Mon Sep 17 00:00:00 2001 From: Martin Nilsson <mani@lysator.liu.se> Date: Sat, 12 Apr 2003 23:44:55 +0200 Subject: [PATCH] int-specific functions here. Rev: lib/modules/Int.pmod:1.1 --- lib/modules/Int.pmod | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 lib/modules/Int.pmod diff --git a/lib/modules/Int.pmod b/lib/modules/Int.pmod new file mode 100644 index 0000000000..69991bf0c2 --- /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; +} -- GitLab