Export (0) Print
Expand All
Expand Minimize
1 out of 10 rated this helpful - Rate this topic

Compiler Warning (level 2) C4244

Error Message

'argument' : conversion from 'type1' to 'type2', possible loss of data

A floating point type was converted to an integer type. A possible loss of data may have occurred.

If you get C4244, you should either change your program to use compatible types, or add some logic to your code, to ensure that the range of possible values will always be compatible with the types you are using.

C4244 can also fire at level 3, and 4; see Compiler Warning (levels 3 and 4) C4244 for more information.

Example

The following sample generates C4244:

// C4244_level2.cpp
// compile with: /W2

int f(int x){ return 0; }
int main() {
   double x = 10.1;
   int i = 10;
   return (f(x));   // C4244
   // try the following line instead
   // return (f(i));
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.