@@ -124,6 +124,14 @@ public void testAllTypesWithRequestToOldNodes() throws Exception {
124
124
builder .append ("\" geo_point_field\" :{\" lat\" :\" 37.386483\" , \" lon\" :\" -122.083843\" }," );
125
125
fieldValues .put ("geo_point_field" , "POINT (-122.083843 37.386483)" );
126
126
builder .append ("\" float_field\" :" + randomFloat + "," );
127
+ /*
128
+ * Double.valueOf(float.toString) gets a `double` representing
129
+ * the `float` that we'd get by going through json which is
130
+ * base 10. just casting the `float` to a `double` will get
131
+ * a lower number with a lot more trailing digits because
132
+ * the cast adds *binary* 0s to the end. And those binary
133
+ * 0s don't translate the same as json's decimal 0s.
134
+ */
127
135
fieldValues .put ("float_field" , Double .valueOf (Float .valueOf (randomFloat ).toString ()));
128
136
/*
129
137
* In 7.12.x we got full float precision from half floats
@@ -134,7 +142,7 @@ public void testAllTypesWithRequestToOldNodes() throws Exception {
134
142
float roundedHalfFloat = HalfFloatPoint .sortableShortToHalfFloat (HalfFloatPoint .halfFloatToSortableShort (randomFloat ));
135
143
builder .append ("\" half_float_field\" :\" " + randomFloat + "\" " );
136
144
if (false == halfFloatMightReturnFullFloatPrecision ) {
137
- fieldValues .put ("half_float_field" , roundedHalfFloat );
145
+ fieldValues .put ("half_float_field" , Double . valueOf ( Float . toString ( roundedHalfFloat )) );
138
146
}
139
147
}
140
148
}
@@ -171,6 +179,14 @@ public void testAllTypesWithRequestToUpgradedNodes() throws Exception {
171
179
builder .append ("\" geo_point_field\" :{\" lat\" :\" 37.386483\" , \" lon\" :\" -122.083843\" }," );
172
180
fieldValues .put ("geo_point_field" , "POINT (-122.083843 37.386483)" );
173
181
builder .append ("\" float_field\" :" + randomFloat + "," );
182
+ /*
183
+ * Double.valueOf(float.toString) gets a `double` representing
184
+ * the `float` that we'd get by going through json which is
185
+ * base 10. just casting the `float` to a `double` will get
186
+ * a lower number with a lot more trailing digits because
187
+ * the cast adds *binary* 0s to the end. And those binary
188
+ * 0s don't translate the same as json's decimal 0s.
189
+ */
174
190
fieldValues .put ("float_field" , Double .valueOf (Float .valueOf (randomFloat ).toString ()));
175
191
/*
176
192
* In 7.12.x we got full float precision from half floats
@@ -181,7 +197,7 @@ public void testAllTypesWithRequestToUpgradedNodes() throws Exception {
181
197
float roundedHalfFloat = HalfFloatPoint .sortableShortToHalfFloat (HalfFloatPoint .halfFloatToSortableShort (randomFloat ));
182
198
builder .append ("\" half_float_field\" :\" " + randomFloat + "\" " );
183
199
if (false == halfFloatMightReturnFullFloatPrecision ) {
184
- fieldValues .put ("half_float_field" , roundedHalfFloat );
200
+ fieldValues .put ("half_float_field" , Double . valueOf ( Float . toString ( roundedHalfFloat )) );
185
201
}
186
202
}
187
203
}
0 commit comments