fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5. int main ()
  6. {
  7. string pi = "pi is " + to_string(3.1415926);
  8. cout<< "pi = "<< pi << endl;
  9.  
  10. cout<<"to_string is available since "+ to_string(2011) << " so use it!";
  11.  
  12. int16_t binary = std::stoi("25");
  13. uint8_t icTmp = 0;
  14. bool negative = false;
  15. if(binary < 0) {
  16. icTmp = -binary;
  17. negative = true;
  18. } else {
  19. icTmp = binary;
  20. }
  21.  
  22. std::cout << "Binary: " << unsigned(icTmp) << " negative: " << (negative ? "true" : "false") << '\n';
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
pi = pi is 3.141593
to_string is available since 2011 so use it!Binary: 25 negative: false