php用asp文件js,JS,PHP,ASP中的ceil()函数

本文对比了JavaScript的Math.ceil()、ASP的Ceil()函数和PHP的ceil()在处理浮点数向上取整操作的实例,展示了在不同编程语言中的使用方法和输出结果,适合初学者理解基本数学函数在不同环境中的表现。
摘要由CSDN通过智能技术生成

document.write( "JS中的Math.ceil():
")

document.write(Math.ceil(0.60) + "
")

document.write(Math.ceil(0.40) + "
")

document.write(Math.ceil(5) + "
")

document.write(Math.ceil(5.1) + "
")

document.write(Math.ceil(-5.1) + "
")

document.write(Math.ceil(-5.9) + "
")

response.Write "
ASP用的ceil():
"

response.Write Ceil(0.60)&"
"

response.Write Ceil(0.40)&"
"

response.Write Ceil(5)&"
"

response.Write Ceil(5.1)&"
"

response.Write Ceil(-5.1)&"
"

response.Write Ceil(-5.9)&"
"

Function Ceil(inNum)

Dim nNum, tempInt

nNum = Fix(inNum)

If inNum > nNum Then

tempInt = nNum + 1

Else

tempInt = nNum

End If

Ceil = tempInt

End Function

%>

echo "
PHP用的ceil():
";

echo Ceil(0.60)."
";

echo Ceil(0.40)."
";

echo Ceil(5)."
";

echo Ceil(5.1)."
";

echo Ceil(-5.1)."
";

echo Ceil(-5.9)."
";

?>

显示结果:

JS中的Math.ceil():

1

1

5

6

-5

-5

ASP用的ceil()

1

1

5

6

-5

-5

ASP用的ceil():

"

'response.Write Ceil(0.60)&"

"

'response.Write Ceil(0.40)&"

"

'response.Write Ceil(5)&"

"

'response.Write Ceil(5.1)&"

"

'response.Write Ceil(-5.1)&"

"

'response.Write Ceil(-5.9)&"

"

'

'Function Ceil(inNum)

' Dim nNum, tempInt

' nNum = Fix(inNum)

'If inNum > nNum Then

'tempInt = nNum + 1

'Else

' tempInt = nNum

'End If

'Ceil = tempInt

'End Function

%>

PHP用的ceil():

1

1

5

6

-5

-5

分享到:更多

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值