99999久久久久久亚洲,欧美人与禽猛交狂配,高清日韩av在线影院,一个人在线高清免费观看,啦啦啦在线视频免费观看www

熱線電話:13121318867

登錄
2021-02-28 閱讀量: 424
python有什么函數(shù)可以進行精確度處理

問:

python有什么函數(shù)可以進行精確度處理


答:

Python的定義允許使用不同的函數(shù)以多種方式處理浮點數(shù)的精度。其中大多數(shù)是在“ math”模塊下定義的。本文將討論一些最常用的函數(shù)。

1. trunc(): -此函數(shù)用于消除浮點數(shù)的所有小數(shù)部分,并返回不帶小數(shù)部分的整數(shù)。

2. ceil(): -此函數(shù)用于打印大于給定數(shù)字最小整數(shù)。

3. floor(): -此函數(shù)用于打印小于給定整數(shù)最大整數(shù)


# Python code to demonstrate ceil(), trunc()

# and floor()


# importing "math" for precision function

import math


# initializing value

a = 3.4536


# using trunc() to print integer after truncating

print ("The integral value of number is : ",end="")

print (math.trunc(a))


# using ceil() to print number after ceiling

print ("The smallest integer greater than number is : ",end="")

print (math.ceil(a))


# using floor() to print number after flooring

print ("The greatest integer smaller than number is : ",end="")

print (math.floor(a))


輸出 :

The integral value of number is : 3
The smallest integer greater than number is : 4
The greatest integer smaller than number is : 3


41.0846
0
關(guān)注作者
收藏
評論(0)

發(fā)表評論

暫無數(shù)據(jù)
推薦帖子