gpt4 book ai didi

mysql - 尝试保存小数时始终保存 999.999999

转载 作者:行者123 更新时间:2023-11-30 00:55:07 28 4
gpt4 key购买 nike

我想将某个地址的纬度/经度保存到我的 mysql 数据库中。获取纬度/经度的部分工作完美。在提交表单之前,我确保经度和纬度保存在表单的两个隐藏字段中。

隐藏字段具有正确的值,例如:

<input class="longitude" data-val="true" data-val-number="The field Longitude must be a number." data-val-required="The Longitude field is required." id="Address_Longitude" name="Address.Longitude" type="hidden" value="3.433212400000002">

在我的创建操作中,我收到以下纬度/经度:

Latitude: 509071452M
Longitude: 3433212400000002M

然后我尝试将其转换为十进制,如下所示:

viewModel.Address.Latitude = Convert.ToDecimal(viewModel.Address.Latitude);

但他总是将999.999999保存在数据库中。

在我的 mysql 数据库中,我有 2 个字段纬度/经度,均为 Decimal(9,6)。

在我的地址模式中:

public Decimal Latitude { get; set; }
public Decimal Longitude { get; set; }

最佳答案

我认为这个值是3.433212400000002,在我的支持中被解释为“数千”..
我将 . 更改为 , 并且它已修复!

关于mysql - 尝试保存小数时始终保存 999.999999,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20638482/

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