From 6d4768761c73582467ab684d87c5d8094639e1c9 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 25 Oct 2021 18:30:53 +0100 Subject: [PATCH] add two new functions to PartType: get_num_elements and get_el_range --- src/ieee754/part/partsig.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/ieee754/part/partsig.py b/src/ieee754/part/partsig.py index 61b64e66..cf1e6678 100644 --- a/src/ieee754/part/partsig.py +++ b/src/ieee754/part/partsig.py @@ -59,6 +59,24 @@ for name in ['add', 'eq', 'gt', 'ge', 'ls', 'xor', 'bool', 'all']: modnames[name] = 0 +def get_runlengths(pbit, size): + res = [] + count = 1 + # identify where the 1s are, which indicates "start of a new partition" + # we want a list of the lengths of all partitions + for i in range(size): + if pbit & (1<