diff options
| author | Tyge Løvset <[email protected]> | 2022-06-01 16:28:07 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-06-01 16:28:07 +0200 |
| commit | de629774cb912aa3d563f24d99258142713c3fcd (patch) | |
| tree | c37e2851d6cb049bc0863a59b6ecf5945fb88619 /examples/bits2.c | |
| parent | 7fb43a24a17da787dd809114ca26c1231b058493 (diff) | |
| download | STC-modified-de629774cb912aa3d563f24d99258142713c3fcd.tar.gz STC-modified-de629774cb912aa3d563f24d99258142713c3fcd.zip | |
Converted all files with DOS line endings to LINUX.
Diffstat (limited to 'examples/bits2.c')
| -rw-r--r-- | examples/bits2.c | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/examples/bits2.c b/examples/bits2.c index af87df42..4b16ad76 100644 --- a/examples/bits2.c +++ b/examples/bits2.c @@ -1,43 +1,43 @@ -#include <stdio.h>
-// Example of static sized (stack allocated) bitsets
-
-#define i_type Bits
-#define i_len 80 // enable fixed bitset on the stack
-#define i_implement
-#include <stc/cbits.h>
-
-int main()
-{
- Bits s1 = Bits_from("1110100110111");
-
- printf("size %" PRIuMAX "\n", Bits_size(&s1));
- char buf[256];
- Bits_to_str(&s1, buf, 0, -1);
- printf("buf: %s: count=%" PRIuMAX "\n", buf, Bits_count(&s1));
-
- Bits_reset(&s1, 8);
- c_autobuf (str, char, Bits_size(&s1) + 1)
- printf(" s1: %s\n", Bits_to_str(&s1, str, 0, -1));
-
- Bits s2 = Bits_clone(s1);
-
- Bits_flip_all(&s2);
- Bits_reset(&s2, 66);
- Bits_reset(&s2, 67);
- printf(" s2: ");
- c_forrange (i, Bits_size(&s2))
- printf("%d", Bits_test(&s2, i));
- puts("");
-
- printf("xor: ");
- Bits_xor(&s1, &s2);
- c_forrange (i, Bits_size(&s1))
- printf("%d", Bits_test(&s1, i));
- puts("");
-
- printf("all: ");
- Bits_set_pattern(&s1, 0x3333333333333333);
- c_forrange (i, Bits_size(&s1))
- printf("%d", Bits_test(&s1, i));
- puts("");
-}
+#include <stdio.h> +// Example of static sized (stack allocated) bitsets + +#define i_type Bits +#define i_len 80 // enable fixed bitset on the stack +#define i_implement +#include <stc/cbits.h> + +int main() +{ + Bits s1 = Bits_from("1110100110111"); + + printf("size %" PRIuMAX "\n", Bits_size(&s1)); + char buf[256]; + Bits_to_str(&s1, buf, 0, -1); + printf("buf: %s: count=%" PRIuMAX "\n", buf, Bits_count(&s1)); + + Bits_reset(&s1, 8); + c_autobuf (str, char, Bits_size(&s1) + 1) + printf(" s1: %s\n", Bits_to_str(&s1, str, 0, -1)); + + Bits s2 = Bits_clone(s1); + + Bits_flip_all(&s2); + Bits_reset(&s2, 66); + Bits_reset(&s2, 67); + printf(" s2: "); + c_forrange (i, Bits_size(&s2)) + printf("%d", Bits_test(&s2, i)); + puts(""); + + printf("xor: "); + Bits_xor(&s1, &s2); + c_forrange (i, Bits_size(&s1)) + printf("%d", Bits_test(&s1, i)); + puts(""); + + printf("all: "); + Bits_set_pattern(&s1, 0x3333333333333333); + c_forrange (i, Bits_size(&s1)) + printf("%d", Bits_test(&s1, i)); + puts(""); +} |
