English Български

Converting Floating Point Number to Integer

The following C++ code snippet converts a floating point number to integer using the type-casting operator static_cast. As a result the variable nPiInt will get value 3.

  1. double nPiDouble = 3.14159;
  2. int nPiInt = static_cast<int>(nPiDouble);

Categories: