Monday 4 March 2019

Different Integer

In C++, you have a huge amount of varieties of numbers. When you add unsigned in front of a type like int (except : bool, char) then the type will no longer support negative numbers.
  • Bool  0 or 1
  • Char  0 to 9
  • Short  - 2^16 to 2^16
  • Int (32 bits) -2^32 to 2^32
  • Long or long long -2^63 to 2^63
  • Unsigned long long 0 to 2^64
You also have complex numbers in C++ if you include the following line : #include <complex>
When you have included that line, you can :
  • initialise a complex table like this : complex<double> mycomplex(10.0,0.01);
  • print the real part with real()
  • print the imaginary part with imag()
  • print the phase angle of a complex number with arg()
  • print the complex projection with proj()
  • print the complex conjugate with conj()
  • print the norm of a complex  number with norm()
  • print absolute value of a complex number with abs()
  • ......

No comments:

Post a Comment

std::next_permutation(arr.begin(),arr.end());

What is next_permutation(a.begin(),a.end()) ? Next permutation is like what its name says, finds the next permutation of a and assigns ...