跳转到内容

模板:Ceil:修订间差异

来自天灾之下:危险连接资料站
wiki>Pppery
无编辑摘要
 
小 导入1个版本
 
(没有差异)

2025年12月16日 (二) 16:40的最新版本


This template produces an expression for the value of a given expression, rounded up to an integer. If the value is in the range of integer-type numbers, the resulting expression is of type integer.

Thus, when applying #expr, if the value is in the range of integer-type numbers the exact result is produced. The reason for not applying #expr in this template is:

  • for integer-type numbers: in subsequent use in another expression the value would be rounded to float
  • for floats: they would be rounded to 14 digits

Examples:

  • {{ceil|123.45}} → floor((123.45))
  • {{ceil|10/7}} → floor((10/7))
  • {{ceil|123.45e20}} → (123.45e20)

Advantage compared with the function ceil:

  • for integer-type numbers with an absolute value between 2^53 and 2^63 the function rounds to float (not necessarily upward), while the template gives the integer-type expression for the exact result