Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "octet.h"
- #include <string>
- Octet::Octet(int a)
- {
- numerique = a;
- //ctor
- }
- Octet::Octet()
- {
- //ctor
- }
- Octet::~Octet()
- {
- //dtor
- }
- void Octet::setOctet(int a)
- {
- numerique = a;
- }
- int Octet::getOctet()
- {
- return numerique;
- }
- std::string Octet::ToBits()
- {
- std::string rep = "";
- int a = numerique; // ne recupère pas la bonne valeurs :(
- int comp = 128;
- for(int i =0; i<8; i++)
- {
- if(a < comp)
- { rep = rep + "0";
- }
- else
- { rep = rep + "1";
- a = a - comp;
- }
- comp = comp/2;
- }
- return rep;
- }
Advertisement
Add Comment
Please, Sign In to add comment