Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ display numbers as binary

#include <iostream>
#include <bitset>

int main() {
    int a = -58, b = a>>3, c = -315;

    std::cout << "a = " << std::bitset<8>(a)  << std::endl;
    std::cout << "b = " << std::bitset<8>(b)  << std::endl;
    std::cout << "c = " << std::bitset<16>(c) << std::endl;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ rand() 
Cpp :: newline in c++ 
Cpp :: write variable to file cpp 
Cpp :: cout hello world 
Cpp :: dlopen failed: library "libomp.so" not found 
Cpp :: c++ Modulo 10^9+7 (1000000007) 
Cpp :: c ++ program to search hashmap 
Cpp :: recursive power in c++ 
Cpp :: quick sort c++ 
Cpp :: cout.flush() in c++ 
Cpp :: c++ virtual function in constructor 
Cpp :: c++ how to convert string to long long 
Cpp :: rank() in c++ 
Cpp :: cpp take lambda as parameter 
Cpp :: how to change string to lowercase and uperCase in c++ 
Cpp :: loop through char in string c++ 
Cpp :: c++ how to check whether a file exists? 
Cpp :: c++ code for insertion sort 
Cpp :: how to run a c++ file from terminal linux 
Cpp :: how to check size of file in c++ 
Cpp :: adding elements to a vector c++ 
Cpp :: c++ declare variable 
Cpp :: string to int in c++ 
Cpp :: arguments to a class instance c++ 
Cpp :: c++ terminal color 
Cpp :: c++ function for checking if a sting is a number 
Cpp :: sleep c++ 
Cpp :: remove element from array c++ 
Cpp :: vector reverse function in c++ 
Cpp :: c++ remove last character from string 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =