Float (floating-point) function detailed

Source: Internet
Author: User

class Float (object):
"""
Floating point number, float (x)

Convert a string or number to a floating point number, if possible.
"""
def as_integer_ratio (self):
"" "gets the simplest ratio of the value of the change" ""
"""
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
Print (Float.as_integer_ratio (1.0)) 1

def conjugate (self, *args, **kwargs): # Real Signature Unknown
"" "Return self, the complex conjugate of any float." "" "
Pass

def fromhex (self, string):
"" To convert a hexadecimal string to a floating-point "" "
"""
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):
"" Returns the 16 binary representation of the current value "" "
"""
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 ""
Print (Float.hex (1.0)) 0x1.0000000000000p+0

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
Absolute

def __add__ (self, y):
"" "X.__add__ (y) <==> x+y" ""
Pass
Addition

def __coerce__ (self, y):
"" "x.__coerce__ (y) <==> coerce (x, y)" ""
Pass


def __divmod__ (self, y):
"" "X.__divmod__ (y) <==> divmod (x, y)" ""
Pass
Print (float.__divmod__ (4.0,2)) (2.0, 0.0) Floating-point addition, remainder decimal

def __div__ (self, y):
"" "X.__div__ (y) <==> x/y" ""
Pass


def __eq__ (self, y):
"" "X.__eq__ (y) <==> x==y" ""
Pass
Print (float.__eq__ (1.0,1.0)) True if equal

def __float__ (self):
"" "x.__float__ () <==> float (x)" ""
Pass
Print (float.__float__ (2.0)) 2.0 Convert to Decimal

def __floordiv__ (self, y):
"" "X.__floordiv__ (y) <==> x//y" ""
Pass
Print (float.__floordiv__ (5.0,2.0)) 2.0 divisible

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 the use of 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
Greater than or equal to print (float.__ge__ (2.0,1.0)) True

def __gt__ (self, y):
"" "X.__gt__ (y) <==> x>y" ""
Pass
Greater than

def __hash__ (self):
"" "x.__hash__ () <==> hash (x)" ""
Pass
Print (float.__hash__ (5.0)) 5 minus decimals

def __init__ (self, x):
Pass
Print (float.__init__ (2.0)) null value

def __int__ (self):
"" "x.__int__ () <==> int (x)" ""
Pass
Convert to Integer print (float.__int__ (1.0)) 1


def __le__ (self, y):
"" "x.__le__ (y) <==> x<=y" ""
Pass
Less than or equal
Print (float.__le__ (1.0,2.0)) True


def __long__ (self):
"" "x.__long__ () <==> Long (x)" ""
Pass
Convert to Long-integer



def __lt__ (self, y):
"" "X.__lt__ (y) <==> x<y" ""
Pass
Less than

def __mod__ (self, y):
"" "X.__mod__ (y) <==> x%y" ""
Pass
Take the remainder
Print (float.__mod__ (2.0,1.0)) 0.0

def __mul__ (self, y):
"" "X.__mul__ (y) <==> x*y" ""
Pass
By

Print (float.__mul__ (1.0,2.0)) 2.0

def __neg__ (self):
"" "x.__neg__ () <==>-X" ""
Pass
Print (float.__neg__ (1.0))-1.0 Convert to negative

@staticmethod # known case of __new__
def __new__ (S, *more):
"" "T.__new__ (S, ...) A new object with type S, a subtype of T "" "
Pass

def __ne__ (self, y):
"" "x.__ne__ (y) <==> x!=y" ""
Pass
is unequal print (float.__ne__ (1.0,1.0)) False

def __nonzero__ (self):
"" "x.__nonzero__ () <==> x! = 0" ""
Pass
is not equal to 0

def __pos__ (self):
"" "x.__pos__ () <==> +x" ""
Pass


def __pow__ (self, Y, Z=none):
"" "X.__pow__ (y[, z]) <==> pow (x, y[, z])" ""
Pass

def __radd__ (self, y):
"" "X.__radd__ (y) <==> y+x" ""
Pass
Add

def __rdivmod__ (self, y):
"" "X.__rdivmod__ (y) <==> divmod (y, x)" ""
Pass
Print (float.__rdivmod__ (2.0,1.0)) to remove the remainder (0.0, 1.0)


def __rdiv__ (self, y):
"" "X.__rdiv__ (y) <==> y/x" ""
Pass
Except


def __repr__ (self):
"" "x.__repr__ () <==> repr (x)" ""
Pass



def __rfloordiv__ (self, y):
"" "X.__rfloordiv__ (y) <==> y//x" ""
Pass
Floor removal

def __rmod__ (self, y):
"" "X.__rmod__ (y) <==> y%x" ""
Pass
Take the remainder

def __rmul__ (self, y):
"" "X.__rmul__ (y) <==> y*x" ""
Pass
By

def __rpow__ (self, x, Z=none):
"" "Y.__rpow__ (x[, z]) <==> pow (x, y[, z])" ""
Pass

def __rsub__ (self, y):
"" "X.__rsub__ (y) <==> y-x" ""
Pass

Print (float.__rsub__ (1.0,2.0)) 1.0 minus


def __rtruediv__ (self, y):
"" "X.__rtruediv__ (y) <==> y/x" ""
Pass
Print (float.__rtruediv__ (2.0,1.0)) 0.5 Division


def __setformat__ (self, Typestr, FMT):
"""
Float.__setformat__ (Typestr, FMT), None

You probably don ' t want the use of this function. It exists mainly to be
Used in Python ' s test suite.

Typestr must be ' double ' or ' float '. FMT must be one of ' unknown ',
' IEEE, Big-endian ' or ' IEEE, Little-endian ', and in addition can is only
One of the latter if it appears to match the underlying C reality.

Override the automatic determination of c-level floating point type.
This affects how floats is converted to and from binary strings.
"""
Pass

def __str__ (self):
"" "x.__str__ () <==> str (x)" ""
Pass
Print (float.__str__ (1.0)) Convert to character

def __sub__ (self, y):
"" "X.__sub__ (y) <==> x-y" ""
Pass
Print (float.__sub__ (2.0,1.0)) 1.0 subtraction

def __truediv__ (self, y):
"" "X.__truediv__ (y) <==> x/y" ""
Pass
Print (float.__truediv__ (3.0,1.5)) divisible

def __trunc__ (self, *args, **kwargs): # Real Signature Unknown
"" "Return the Integral closest to x between 0 and X." "" "
Pass


Imag = Property (Lambda self:object (), Lambda-Self, v:none, lambda self:none) # Default
"" "The imaginary part of a complex number" ""

Real = Property (Lambda self:object (), Lambda-Self, v:none, lambda self:none) # Default
"" "The real part of a complex number" ""

Float

Float (floating-point) function detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.