【发布时间】:2019-12-02 12:23:06
【问题描述】:
例如,我试图将数字 1.86 保存在 CloudFirestore 中,但数字 1.8600000143051147 出现在控制台中。这是正常机制还是我犯了错误?
在应用中:
在控制台中:
代码:
String name = selectedProduct.getName();
float carbohydrates = Float.parseFloat(textViewCarbohydratesSaveProduct.getText().toString().split("\\ ")[1]);
float protein = Float.parseFloat(textViewProteinSaveProduct.getText().toString().split("\\ ")[1]);
float fat = Float.parseFloat(textViewFatSaveProduct.getText().toString().split("\\ ")[1]);
float weight = Float.parseFloat(editTextCurrentWeightSaveProduct.getText().toString());
float calories = Float.parseFloat(textViewCaloriesSaveProduct.getText().toString().split("\\ ")[1]);
Product newProduct = new Product(name, carbohydrates, protein, fat, weight, calories);
firebaseFirestore.collection("Users").document(currentUser)
.collection("Type of Meal").document(typeOfMeal)
.collection("Date of breakfast").document(date).set(newProduct);
【问题讨论】:
标签: java android firebase google-cloud-firestore