python math.modf()方法

math.modf()方法

python的标准库math中的modf()方法,可以元素值为浮点数的类型值的元组返回参数x的小数部分和整数部分,符号与x的值相同。


modf()语法

modf(x)

python源码对modf()方法的介绍:

    Return the fractional and integer parts of x.  Both results carry the sign
    of x and are floats.

参数

参数描述
x必须参数,real number

返回值

以元组类型返回,元组中的元素为python浮点数类型。


math.modf()方法实例代码

>>> import math
>>> math.modf(1)
(0.0, 1.0)
>>> math.modf(0)
(0.0, 0.0)

全栈后端 / Python库 :









Copyright © 2022-2024 笨鸟工具 x1y1z1.com All Rights Reserved.