29 |
|
|
30 |
|
if (off != 0) |
31 |
|
{ |
32 |
< |
bytes.push_back(0); |
32 |
> |
bytes.push_back(0); |
33 |
|
string.insert(0, 8 - off, signed_ && string[0] == '1' ? '1' : '0'); |
34 |
|
} |
35 |
|
|
36 |
|
std::string::size_type index(0); |
37 |
|
|
38 |
< |
_rmforeach (std::vector<char>, byte, bytes) |
39 |
< |
{ |
40 |
< |
_rfor (char, bit, 0, 8) |
41 |
< |
{ |
42 |
< |
*byte |= (string[index++] == '1') << bit; |
43 |
< |
} |
44 |
< |
} |
38 |
> |
_rmforeach (std::vector<char>, byte, bytes) _rfor (char, bit, 0, 8) *byte |= (string[index++] == '1') << bit; |
39 |
|
} |
40 |
|
|
41 |
|
template <typename Type> |
78 |
|
{ |
79 |
|
std::string hello("Hello, World!"); |
80 |
|
|
81 |
< |
_foreach (std::string, atom, hello) |
88 |
< |
{ |
89 |
< |
std::cout << Binary(*atom) << " = " << *atom << std::endl; |
90 |
< |
} |
81 |
> |
_foreach (std::string, atom, hello) std::cout << Binary(*atom) << " = " << *atom << std::endl; |
82 |
|
|
83 |
< |
_fori (index, -10, 11) |
93 |
< |
{ |
94 |
< |
std::cout << Binary(index) << " = " << index << std::endl; |
95 |
< |
} |
83 |
> |
_fori (index, -10, 11) std::cout << Binary(index) << " = " << index << std::endl; |
84 |
|
|
85 |
< |
_foru (index, -10, 11) |
98 |
< |
{ |
99 |
< |
std::cout << Binary(index) << " = " << index << std::endl; |
100 |
< |
} |
85 |
> |
_foru (index, -10, 11) std::cout << Binary(index) << " = " << index << std::endl; |
86 |
|
|
87 |
< |
for (float index(-1.0); index < 1.0; index += 0.1) |
103 |
< |
{ |
104 |
< |
std::cout << Binary(index) << " = " << index << std::endl; |
105 |
< |
} |
87 |
> |
for (float index(-1.0); index < 1.0; index += 0.1) std::cout << Binary(index) << " = " << index << std::endl; |
88 |
|
|
89 |
< |
for (double index(-1.0); index < 1.0; index += 0.1) |
108 |
< |
{ |
109 |
< |
std::cout << Binary(index) << " = " << index << std::endl; |
110 |
< |
} |
89 |
> |
for (double index(-1.0); index < 1.0; index += 0.1) std::cout << Binary(index) << " = " << index << std::endl; |
90 |
|
|
91 |
|
std::string string("101001101001"); |
92 |
|
Binary binary(string, true); |