python之浮点型类型
2021-05-18 06:29
标签:ever original tom str point main match == att 浮点型:float 如3.14,2.88 python之浮点型类型 标签:ever original tom str point main match == att 原文地址:https://www.cnblogs.com/pythonlearing/p/9744957.htmlclass float(object):
"""
float(x) -> floating point number
Convert a string or number to a floating point number, if possible.
"""
def as_integer_ratio(self):
""" 获取改值的最简比 """
"""
float.as_integer_ratio() -> (int, int)
Return a pair of integers, whose ratio is exactly equal to the original
float and with a positive denominator.
Raise OverflowError on infinities and a ValueError on NaNs.
>>> (10.0).as_integer_ratio()
(10, 1)
>>> (0.0).as_integer_ratio()
(0, 1)
>>> (-.25).as_integer_ratio()
(-1, 4)
"""
pass
def conjugate(self, *args, **kwargs): # real signature unknown
""" Return self, the complex conjugate of any float. """
pass
def fromhex(self, string):
""" 将十六进制字符串转换成浮点型 """
"""
float.fromhex(string) -> float
Create a floating-point number from a hexadecimal string.
>>> float.fromhex(‘0x1.ffffp10‘)
2047.984375
>>> float.fromhex(‘-0x1p-1074‘)
-4.9406564584124654e-324
"""
return 0.0
def hex(self):
""" 返回当前值的 16 进制表示 """
"""
float.hex() -> string
Return a hexadecimal representation of a floating-point number.
>>> (-0.1).hex()
‘-0x1.999999999999ap-4‘
>>> 3.14159.hex()
‘0x1.921f9f01b866ep+1‘
"""
return ""
def is_integer(self, *args, **kwargs): # real signature unknown
""" Return True if the float is an integer. """
pass
def __abs__(self):
""" x.__abs__() abs(x) """
pass
def __add__(self, y):
""" x.__add__(y) x+y """
pass
def __coerce__(self, y):
""" x.__coerce__(y) coerce(x, y) """
pass
def __divmod__(self, y):
""" x.__divmod__(y) divmod(x, y) """
pass
def __div__(self, y):
""" x.__div__(y) x/y """
pass
def __eq__(self, y):
""" x.__eq__(y) x==y """
pass
def __float__(self):
""" x.__float__() float(x) """
pass
def __floordiv__(self, y):
""" x.__floordiv__(y) x//y """
pass
def __format__(self, format_spec):
"""
float.__format__(format_spec) -> string
Formats the float according to format_spec.
"""
return ""
def __getattribute__(self, name):
""" x.__getattribute__(‘name‘) x.name """
pass
def __getformat__(self, typestr):
"""
float.__getformat__(typestr) -> string
You probably don‘t want to use this function. It exists mainly to be
used in Python‘s test suite.
typestr must be ‘double‘ or ‘float‘. This function returns whichever of
‘unknown‘, ‘IEEE, big-endian‘ or ‘IEEE, little-endian‘ best describes the
format of floating point numbers used by the C type named by typestr.
"""
return ""
def __getnewargs__(self, *args, **kwargs): # real signature unknown
pass
def __ge__(self, y):
""" x.__ge__(y) x>=y """
pass
def __gt__(self, y):
""" x.__gt__(y) x>y """
pass
def __hash__(self):
""" x.__hash__() hash(x) """
pass
def __init__(self, x):
pass
def __int__(self):
""" x.__int__() int(x) """
pass
def __le__(self, y):
""" x.__le__(y) x"""
pass
def __long__(self):
""" x.__long__() long(x) """
pass
def __lt__(self, y):
""" x.__lt__(y) x