gpt4 book ai didi

mysql - 是否可以在 MySQL 中将 DECIMAL 转换为 DOUBLE?

转载 作者:可可西里 更新时间:2023-11-01 07:02:50 27 4
gpt4 key购买 nike

我知道所有数值含义,即浮点格式固有的可能舍入问题,但就我而言,我在 MySQL 中有我想要的 DECIMAL 列直接在 MySQL 查询中而不是下游转换为 DOUBLE

有人能帮忙吗?

最佳答案

SELECT my_decimal_field + 0E0 FROM my_table

MySQL 手册中的以下引述解释了它是如何工作的:

9.1.2 Numeric Literals

Number literals include exact-value (integer and DECIMAL) literals and approximate-value (floating-point) literals.

Numbers represented in scientific notation with a mantissa and exponent are approximate-value numbers.

12.22.3 Expression Handling

Handling of a numeric expression depends on what kind of values the expression contains:

  • If any approximate values are present, the expression is approximate and is evaluated using floating-point arithmetic.

关于mysql - 是否可以在 MySQL 中将 DECIMAL 转换为 DOUBLE?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12742322/

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