MCPcopy Create free account
hub / github.com/DFHack/dfhack / print_bits

Function print_bits

library/include/MiscUtils.h:66–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64
65template <typename T>
66void print_bits ( T val, std::ostream& out )
67{
68 std::stringstream strs;
69 T n_bits = sizeof ( val ) * CHAR_BIT;
70 int cnt;
71 for ( unsigned i = 0; i < n_bits; ++i )
72 {
73 cnt = i/10;
74 strs << cnt << " ";
75 }
76 strs << std::endl;
77 for ( unsigned i = 0; i < n_bits; ++i )
78 {
79 cnt = i%10;
80 strs << cnt << " ";
81 }
82 strs << std::endl;
83 for ( unsigned i = 0; i < n_bits; ++i )
84 {
85 strs << "--";
86 }
87 strs << std::endl;
88 for ( unsigned i = 0; i < n_bits; ++i )
89 {
90 strs<< !!( val & 1 ) << " ";
91 val >>= 1;
92 }
93 strs << std::endl;
94 out << strs.str();
95}
96
97/*
98 * Binary search in vectors.

Callers

nothing calls this directly

Calls 1

strMethod · 0.45

Tested by

no test coverage detected