java - Float vs Integer MAX_VALUE -


int , float has 4 bytes value.

if there such float value 0.5 int doesn't contain, there value int contains, float.

i'm assuming you're looking numbers can presented int, not float.

one of them integer.max_value.

int = integer.max_value; float f = i;      // or 2147483647f system.out.println(i); system.out.println(string.format("%f", f)); 

displays

2147483647 2147483648.000000 

this because while both have 32-bits float divides bits used sign (1 bit), exponent (8 bits) , significand or mantissa (23 bits).


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -