It is possible to convert 24 bit integer
value into float
and then back to 24 bit integer
without losing data?
For example, let's consider 8 bit int, a byte, range is [-127..127] (we drop -128).
public static float ToFloatSample (byte x) { return x / 127f; }
So, if x == -127
, result will be -1
, if x == 127
, result will be 1
. If x == 64
, result will be ~0.5
public static int ToIntSample (float x) { return (int) (x * 127f); }
So now:
int x = some_number;
float f = ToFloatSample (x);
int y = ToIntSample (f);
Will always x == y
? Using 8 bit int yes, but what if I use 24 bit?