T.T*_*.T. 5 c++ windows variables types
warning C4244: '=' : conversion from 'unsigned int' to 'float', possible loss of data
Run Code Online (Sandbox Code Playgroud)
Shouldn't a float be able to handle any value from an int?
unsigned int: 0 to 4,294,967,295
float 3.4E +/- 38 (7 digits)
Run Code Online (Sandbox Code Playgroud)
Wiki:
Run Code Online (Sandbox Code Playgroud)The advantage of floating-point representation over fixed-point (andinteger) representation is that it can support a much wider range of values.
Any insight would be helpful, thanks.
http://msdn.microsoft.com/en-us/library/s3f49ktz%28VS.80%29.aspx
While float supports a wider range of values than unsigned int, it does so with less accuracy. Floats have a 23-bit mantissa which, as you posted, is only about 7 decimal digits. unsigned ints support over 9 decimal digits.
Suggestion: use double, not float.
Edit:
Actually, I retract that suggestion; floating-point and integer data types are fundamentally different and are not directly convertible. What integer value do you expect to get for Single.MaxValue? For Single.NegativeInfinity? Explaining why you want to convert from float to int would be helpful.