ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/Represent/Binary.cpp
(Generate patch)

Comparing Represent/represent.cpp (file contents):
Revision 366 by douglas, 2004-12-21T03:22:38-08:00 vs.
Revision 369 by douglas, 2004-12-21T03:32:17-08:00

# Line 25 | Line 25 | public:
25  
26   Binary::Binary(std::string& string, bool signed_) : bytes(string.size() / 8, 0)
27   {
28 +        if (string.find_first_not_of("01") != std::string::npos) throw;
29 +
30          std::string::size_type off(string.size() % 8);
31  
32          if (off != 0)
33          {
34 <                bytes.push_back(0);
34 >                bytes.push_back(0);
35                  string.insert(0, 8 - off, signed_ && string[0] == '1' ? '1' : '0');
36          }
37  
# Line 78 | Line 80 | int main(int argc, char* argv[])
80   {
81          std::string hello("Hello, World!");
82  
83 <        _foreach (std::string, atom, hello)
82 <        {
83 <                std::cout << Binary(*atom) << " = " << *atom << std::endl;
84 <        }
83 >        _foreach (std::string, atom, hello) std::cout << Binary(*atom) << " = " << *atom << std::endl;
84  
85 <        _fori (index, -10, 11)
87 <        {
88 <                std::cout << Binary(index) << " = " << index << std::endl;
89 <        }
85 >        _fori (index, -10, 11) std::cout << Binary(index) << " = " << index << std::endl;
86  
87 <        _foru (index, -10, 11)
92 <        {
93 <                std::cout << Binary(index) << " = " << index << std::endl;
94 <        }
87 >        _foru (index, -10, 11) std::cout << Binary(index) << " = " << index << std::endl;
88  
89 <        for (float index(-1.0); index < 1.0; index += 0.1)
97 <        {
98 <                std::cout << Binary(index) << " = " << index << std::endl;
99 <        }
89 >        for (float index(-1.0); index < 1.0; index += 0.1) std::cout << Binary(index) << " = " << index << std::endl;
90  
91 <        for (double index(-1.0); index < 1.0; index += 0.1)
102 <        {
103 <                std::cout << Binary(index) << " = " << index << std::endl;
104 <        }
91 >        for (double index(-1.0); index < 1.0; index += 0.1) std::cout << Binary(index) << " = " << index << std::endl;
92  
93          std::string string("101001101001");
94          Binary binary(string, true);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines