FIXValue { public void setFloat(double x, int decimals) { bytes[bytes.length - 1] = SOH; long y = Math.round(POWERS_OF_TEN[decimals] * Math.abs(x)); int i = bytes.length - 2; for (int j = 0; j < decimals; j++) { bytes[i--] = (byte)('0' + y % 10); y /= 10; } if (decimals > 0) bytes[i--] = '.'; do { bytes[i--] = (byte)('0' + y % 10); y /= 10; } while (y > 0); if (x < 0) bytes[i--] = '-'; offset = i + 1; length = bytes.length - 1 - offset; } FIXValue(int capacity); byte byteAt(int index); int length(); boolean contentEquals(byte x); boolean contentEquals(byte[] x); boolean contentEquals(char x); boolean contentEquals(CharSequence x); void copyTo(byte[] bytes); void reset(); void set(FIXValue value); boolean asBoolean(); void setBoolean(boolean x); char asChar(); void setChar(char x); long asInt(); void setInt(long x); double asFloat(); void setFloat(double x, int decimals); String asString(); void asString(Appendable x); void asString(StringBuilder x); void setString(CharSequence x); void asDate(MutableDateTime x); void setDate(ReadableDateTime x); void asTimeOnly(MutableDateTime x); void setTimeOnly(ReadableDateTime x, boolean millis); void asTimestamp(MutableDateTime x); void setTimestamp(ReadableDateTime x, boolean millis); @Deprecated long asCheckSum(); void setCheckSum(long x); boolean get(ByteBuffer buffer); void put(ByteBuffer buffer); @Override String toString(); void toString(StringBuilder builder);  }
@Test public void setFloat() { value.setFloat(12.50, 2); assertPutEquals("12.50\u0001"); }
@Test public void setZeroFloat() { value.setFloat(0.00, 2); assertPutEquals("0.00\u0001"); }
@Test public void setNegativeFloat() { value.setFloat(-12.50, 2); assertPutEquals("-12.50\u0001"); }
@Test public void setFloatWithoutDecimals() { value.setFloat(12.00, 0); assertPutEquals("12\u0001"); }
@Test public void setFloatWithRoundingDown() { value.setFloat(12.50, 2); assertPutEquals("12.50\u0001"); }
@Test public void setFloatWithRoundingUp() { value.setFloat(12.505, 2); assertPutEquals("12.51\u0001"); }