Fixed bug in toBin function

This commit is contained in:
2021-06-29 12:00:12 -04:00
parent 5e3c4bd004
commit 16b2a6f792
2 changed files with 14 additions and 6 deletions

View File

@@ -608,7 +608,7 @@ bool isPalindrome(std::string str){
template <class T>
std::string toBin(T num){
//Convert the number to a binary string
std::string fullString = std::bitset<sizeof(T)>(num).to_string();
std::string fullString = std::bitset<sizeof(T) * 8>(num).to_string();
//Remove leading zeros
int loc = 0;
for(loc = 0;(loc < fullString.size()) && (fullString[loc] == '0');++loc);