IFD:Acoustic Interfaces/introduction to c++: Difference between revisions

From Medien Wiki
No edit summary
No edit summary
Line 1: Line 1:
Little intro to data types:
     #include <iostream>
     #include <iostream>
     #include <string>
     #include <string>

Revision as of 09:10, 11 May 2020

Little intro to data types:

   #include <iostream>
   #include <string>
   using namespace std;
   int main()
   {
       int int_number = 2147483647; // 2^32 / 2 -1 = 2^31 -1 = 2147483648 -1 // -2^31 = -2147483648
       long long_integer = 9223372036854775807; // 2^64 / 2 - 1= 2^63 -1 = 2147483648 -1 // -2^63 = -2147483648
       float low_precision_big_float_number = 9223372036854775807; // 9.22337e+18 = 9.22337 *10^18
       double high_precision_big_float_number = 9223372036854775807; // 9.22337e+18 = 9.22337 *10^18
       
       //char are 8bit = 2^8 = 256 
       char letter_exclamation = 33; // this gets converted through ASCII table to the letter '!'
       char letter_A = 65; // this gets converted through ASCII table to the letter '!'
       
       string text = "this is a string, it's not included by default";
       
       int converted_float = 3.21;
       
       cout << "Integer:  " << int_number << endl; 
       cout << "Long Integer: " << long_integer  << endl; 
       cout << "Overflow Integer:  " << int_number + 1 << endl; 
       cout << "Overflow Long Integer: " << long_integer  +1 << endl; 
       cout << "Low precision Big float: " << low_precision_big_float_number << endl;
       cout << "High precision Big float: " << high_precision_big_float_number << endl; // command line is the bottleneck of putting out more precision
       cout << "Thats the letter '!': " << letter_exclamation << endl; 
       cout << "Thats the letter 'A': " << letter_A << endl; 
       cout << text;
       
       return 0;
   }