SQLite 将浮点值保存为整数

发布于 2024-08-08 09:32:48 字数 202 浏览 3 评论 0原文

我正在使用 System.Data.SQLite 将数据保存到数据库。表中有 2 列定义为浮点数。但是,当我将数据保存到数据库时,它仅保存整数部分。

12.2345=> 12 11.5324=> 11 (我不知道它到底是如何舍入的,它只是舍入)

是的,我确信我在应用程序中使用了浮点数,并且我确信 CommandText 包含浮点数而不是整数。

I'm using System.Data.SQLite to save data to database. In table there are 2 columns defined as float. However when I save data to DB it saves only integer part.

12.2345 => 12
11.5324 => 11
(I don't know how exactly it rounds, it just rounds)

Yes I'm sure I'm using floats in my application, and I'm sure that CommandText contains float numbers NOT integer.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

温馨耳语 2024-08-15 09:32:48

您需要在应用程序中使用浮点数,但还需要确保 SQLite 数据库中的表条目已显式声明为 REAL 类型。

You need to be using floats in your application, but you also need to make sure the table entry in the SQLite database has been explicitly declared to be that REAL type.

娇柔作态 2024-08-15 09:32:48

不支持浮动作为内置类型。请改用文本。

There is no support for floats as build-in type. Use TEXT instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文