type promotion 指在编程语言中,较小或较“窄”的数据类型在表达式计算时被自动提升为较大或较“宽”的类型,以便进行运算或匹配函数参数(常见于 C/C++ 等语言)。例如 char、short 在算术运算中常会先提升为 int。在不同语言里也可能与“隐式类型转换(implicit conversion)”相关,但侧重点在“提升到更高精度/更大范围”。
/taɪp prəˈməʊʃən/
Type promotion can change the result of an arithmetic expression.
类型提升可能会改变算术表达式的计算结果。
In C, integer promotions may convert a char to an int before evaluation, which helps avoid overflow in some cases but can also introduce subtle bugs.
在 C 语言中,整数提升可能会在求值前把 char 转成 int,这在某些情况下有助于避免溢出,但也可能引入细微的 bug。
type 源自希腊语 typos(印记、模型、类型),经拉丁语与法语进入英语;promotion 来自拉丁语 promovere(向前推进、提升)。组合在编程语境中表示“把类型向更高层级/更大表示范围推进”的过程。