Skip to content

Commit

Permalink
Simplified printHexa
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriks committed Dec 15, 2011
1 parent 85ca8ba commit 53ddc48
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions src/interface.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,23 +21,12 @@


std::string printHexa(int n) std::string printHexa(int n)
{ {
std::string s = ""; if (n < 0 || n > 0xFFFF)
return " h";

char c[6]; //como tem 4 numeros + h + \0 char c[6]; //como tem 4 numeros + h + \0
if(n < 16) sprintf(c,"%04Xh", n);
{ return std::string(c);
sprintf(c,"000%xh",n);
s.append(c);
}else if(n < 256){
sprintf(c,"00%xh",n);
s.append(c);
}else if(n < 4096){
sprintf(c,"0%xh",n);
s.append(c);
}else{
sprintf(c,"%xh",n);
s.append(c);
}
return s;
} }


std::string printNome(std::string s) // até 21 caracteres da pra imprimir std::string printNome(std::string s) // até 21 caracteres da pra imprimir
Expand Down

0 comments on commit 53ddc48

Please sign in to comment.