, , , , float. , Java IEEE ( , 754).
, , , 0.5 1, , . , 0.25 1, 0.125 1 , , - :
float a = 1;
float b = 0.5;
int bits = 0;
while (a + b != a) {
bits = bits + 1;
b = b / 2;
}
3 , 1 + 1/16 1.
.
2, 1, IEEE754 "1+" .
EDIT:
, , , , 63 , 4 .
( , [ while (((float)(a + b) != (float)(a))
] ) (, , ) , a
b
, , .
, , , IEEE754 ( ).
. , - , , , ( , : -).
2:
, , . , - .
#include <stdio.h>
#include <float.h>
int main(void) {
float a = 1;
float b = 0.5;
float c = a + b;
int bits = 1;
while (c != a) {
bits = bits + 1;
b = b / 2;
c = a + b;
}
printf("%d\n",FLT_MANT_DIG);
printf("%d\n",bits);
return 0;
}
(24,24), , .
C, ( , , ). C, Eclipse Ubuntu: -).