gpt4 book ai didi

java - Cloud Firestore 保存带有不必要小数位的数字

转载 作者:行者123 更新时间:2023-11-29 04:05:26 25 4
gpt4 key购买 nike

<分区>

例如,我试图在CloudFirestore中保存数字1.86,但是在控制台中却出现数字1.8600000143051147。这是正常机制还是我犯了错误?

应用中:

In application

在控制台中:

In console

代码:

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);

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com