diff options
Diffstat (limited to 'vere/pkg/noun/jets/c/ctz.c')
-rw-r--r-- | vere/pkg/noun/jets/c/ctz.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/vere/pkg/noun/jets/c/ctz.c b/vere/pkg/noun/jets/c/ctz.c new file mode 100644 index 0000000..ff74e24 --- /dev/null +++ b/vere/pkg/noun/jets/c/ctz.c @@ -0,0 +1,34 @@ +/// @file + +#include "jets/q.h" +#include "jets/w.h" + +#include "noun.h" + +u3_atom +u3qc_ctz(u3_atom a) +{ + c3_w wor_w, i_w = 0; + + if ( 0 == a ) { + return 0; + } + + do { + wor_w = u3r_word(i_w++, a); + } + while ( !wor_w ); + + { + c3_w bit_d = i_w - 1; + bit_d *= 32; + bit_d += c3_tz_w(wor_w); + return u3i_chub(bit_d); + } +} + +u3_noun +u3wc_ctz(u3_noun cor) +{ + return u3qc_ctz(u3x_atom(u3h(u3t(cor)))); +} |