天花板函数的 PHP 代码
有人曾经编写过 PHP(或 Perl)函数来获取 Excel 样式的上限值吗?
Anyone has ever programmed a PHP (or Perl) function to get the ceiling value Excel style?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这应该是来自 php.net 评论的答案:
This should be the answer, from php.net comments:
“Microsoft Excel 的上限函数不遵循数学定义,而是与 C 中的 (int) 运算符一样,它是下限函数和上限函数的混合体:对于 x ≥ 0,它返回上限(x),而对于x < 0 则返回 Floor(x)。例如,CEILING(-4.5) 返回 -5。可以使用公式“-”来模拟数学上限函数。 INT(-value)”(请注意,这不是一般规则,因为它取决于 Excel 的 INT 函数,该函数的行为与大多数编程语言不同)。” - 来自 wikipedia
如果 php 内置的 ceil 函数不能正常工作,你可以创建一个新函数,比如
希望有帮助
"Microsoft Excel's ceiling function does not follow the mathematical definition, but rather as with (int) operator in C, it is a mixture of the floor and ceiling function: for x ≥ 0 it returns ceiling(x), and for x < 0 it returns floor(x). This has followed through to the Office Open XML file format. For example, CEILING(-4.5) returns -5. A mathematical ceiling function can be emulated in Excel by using the formula "-INT(-value)" (please note that this is not a general rule, as it depends on Excel's INT function, which behaves differently that most programming languages)." - from wikipedia
If php's built in ceil function isn't working right you could make a new function like
Hope that helps
抱歉,不太清楚“Excel 样式”是什么,但是 PHP 有一个 ceil 函数。
Sorry, not quite clear what 'Excel style' is, but PHP has a ceil function.