python
import math
print(int(3.7)) 输出 3
print(math.trunc(-2.7)) 输出 -2
javascript
console.log(Math.trunc(3.7)); // 输出 3
console.log(Math.trunc(-2.7)); // 输出 -2
java
System.out.println((int)3.7); // 输出 3
System.out.println((int)-2.7); // 输出 -2
python
import math
print(math.floor(3.7)) 输出 3
print(math.floor(-2.7)) 输出 -3
javascript
console.log(Math.floor(3.7)); // 输出 3
console.log(Math.floor(-2.7)); // 输出 -3
根据具体需求选择合适的方法即可。
版权声明: 知妳网保留所有权利,部分内容为网络收集,如有侵权,请联系QQ793061840删除,添加请注明来意。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态