I'm reading file, written with C floats in java.
myFileRead(bptr, 4, n_row, stream);
for (int i=0;i<n_row;i++)
ptr.set(i,Float.intBitsToFloat(ByteBuffer.wrap(bptr,i*4,4)
.order(ByteOrder.LITTLE_ENDIAN).getInt()));
C output:
input[j] -0.0922103971 float
wr[j] 0.00706708990 float
Java output:
input.get(j) = {Float@602} "-0.0922104"
wr.get(j) = {Float@603} "0.00706709"
Java also gives me this:
input.get(j).doubleValue() = -0.09221039712429047
wr.get(j).doubleValue() = 0.0070670899003744125
Then I need to multiply these two values and it doesn't match in two ways.
(input.get(j) * wr.get(j)) = -6.5165915E-4
(input.get(j).doubleValue() * wr.get(j).doubleValue()) = -6.516591662265869E-4
C output:
input[j]*wr[j] -0.000651659153 float
Then error accumulates and after for() cycle
for(j = 0; j < input_size; j++)
z += input.get(j) * wr.get(j);
output.set(i, z);
output is:
C: -2.99740553
Java: -2.7654826641082764
Seems like java Float too short (how does it have double value then?) and Double too long for that. How can I make Java output match C output?