Convert from unsigned int to float

warning C4244: '=' : conversion from 'unsigned int' to 'float', possible loss of data  

Should a float be able to handle any value from int?

unsigned int: 0 to 4,294,967,295  
float 3.4E +/- 38 (7 digits) 

Wiki:

The advantage of floating-point representation over fixed-point (and

integer) 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

+5
source share
5 answers

'unsigned int' 'float' 32 . , . , unsigned int, . MSDN .

+12

float , unsigned int, . 23- , , , 7 . unsigned ints 9 .

: double, float.

Edit: , ; . Single.MaxValue? Single.NegativeInfinity? , float int.

+7

, float 7 , 10 INT_MAX. , C4244 .

+3

wikipedia:

, "float" C, "" "" 4? Fortran. , 32 (4 ), 24 ( 7 ).

int 32 () , 32 ( ), int, .

+3

,

float f = 0.0f;
while (f < (INT_MAX-1))
   f++;

, , int 32 .

, , f , f == f + 1

+2

All Articles