php取整函数ceil,floor,round,intval的区别
Posted 好笑。
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php取整函数ceil,floor,round,intval的区别相关的知识,希望对你有一定的参考价值。
ceil---进一法取整
返回大于value的下一个整数,若value有小数部分则进一位
eg:echo ceil(9.999) //10
floor---舍去法取整
返回小于value的下一个整数,若value有小数部分则舍去取整
eg:echo floor(9.999) //9
intval---对变数转成整数
eg: echo intval(4.3) //4
round---对浮点数进行四舍五入
!--5f39ae17-8c62-4a45-bc43-b32064c9388a:W3siYmxvY2tJZCI6IjQ5ODEtMTU1NTcyOTEyNTEyNCIsImJsb2NrVHlwZSI6InBhcmFncmFwaCIsInN0eWxlcyI6eyJhbGlnbiI6ImxlZnQiLCJpbmRlbnQiOjAsInRleHQtaW5kZW50IjowLCJsaW5lLWhlaWdodCI6MS43NSwiYmFjay1jb2xvciI6IiIsInBhZGRpbmciOiIifSwidHlwZSI6InBhcmFncmFwaCIsInJpY2hUZXh0Ijp7ImRhdGEiOlt7ImNoYXIiOiJjIn0seyJjaGFyIjoiZSJ9LHsiY2hhciI6ImkifSx7ImNoYXIiOiJsIn0seyJjaGFyIjoiLSJ9LHsiY2hhciI6Ii0ifSx7ImNoYXIiOiItIn0seyJjaGFyIjoi6L+bIn0seyJjaGFyIjoi5LiAIn0seyJjaGFyIjoi5rOVIn0seyJjaGFyIjoi5Y+WIn0seyJjaGFyIjoi5pW0In1dLCJpc1JpY2hUZXh0Ijp0cnVlLCJrZWVwTGluZUJyZWFrIjp0cnVlfX0seyJibG9ja0lkIjoiOTc2My0xNTU1NzI5MTYxNTAwIiwiYmxvY2tUeXBlIjoicGFyYWdyYXBoIiwic3R5bGVzIjp7InRleHQtaW5kZW50IjoxLCJhbGlnbiI6ImxlZnQiLCJpbmRlbnQiOjAsImxpbmUtaGVpZ2h0IjoxLjc1LCJiYWNrLWNvbG9yIjoiIiwicGFkZGluZyI6IiJ9LCJ0eXBlIjoicGFyYWdyYXBoIiwicmljaFRleH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In0seyJjaGFyIjoi5rWuIn0seyJjaGFyIjoi54K5In0seyJjaGFyIjoi5pWwIn0seyJjaGFyIjoi6L+bIn0seyJjaGFyIjoi6KGMIn0seyJjaGFyIjoi5ZubIn0seyJjaGFyIjoi6IiNIn0seyJjaGFyIjoi5LqUIn0seyJjaGFyIjoi5YWlIn1dLCJpc1JpY2hUZXh0Ijp0cnVlLCJrZWVwTGluZUJyZWFrIjp0cnVlfX0seyJibG9ja0lkIjoiMjEyNS0xNTU1NzI5NjU2MDkxIiwiYmxvY2tUeXBlIjoicGFyYWdyYXBoIiwic3R5bGVzIjp7ImFsaWduIjoibGVmdCIsImluZGVudCI6MCwidGV4dC1pbmRlbnQiOjAsImxpbmUtaGVpZ2h0IjoxLjc1LCJiYWNrLWNvbG9yIjoiIiwicGFkZGluZyI6IiJ9LCJ0eXBlIjoicGFyYWdyYXBoIiwicmljaFRleHQiOnsiZGF0YSI6W10sImlzUmljaFRleHQiOnRydWUsImtlZXBMaW5lQnJlYWsiOnRydWV9fSx7ImJsb2NrSWQiOiIyMzcwLTE1NTU3Mjk3MDU2MTIiLCJibG9ja1R5cGUiOiJwYXJhZ3JhcGgiLCJzdHlsZXMiOnsiYWxpZ24iOiJsZWZ0IiwiaW5kZW50IjowLCJ0ZXh0LWluZGVudCI6MCwibGluZS1oZWlnaHQiOjEuNzUsImJhY2stY29sb3IiOiIiLCJwYWRkaW5nIjoiIn0sInR5cGUiOiJwYXJhZ3JhcGgiLCJyaWNoVGV4dCI6eyJkYXRhIjpbXSwiaXNSaWNoVGV4dCI6dHJ1ZSwia2VlcExpbmVCcmVhayI6dHJ1ZX19XQ==-->以上是关于php取整函数ceil,floor,round,intval的区别的主要内容,如果未能解决你的问题,请参考以下文章
php取整函数ceil,floor,round,intval的区别
php中除法取整的方法(round,ceil,floor)
C#取整函数Math.RoundMath.Ceiling和Math.Floor
三个函数ceil()floor()round()
三个函数ceil()floor()round()
C#取整函数Math.RoundMath.Ceiling和Math.Floor