学习一门语言都要打好基础,前面的知识可能看着无聊,但是很重要,能够让我们打好坚实的基础,一定要掌握int、float、long、字符串、列表、元组、集合、字典、函数和类的基础常用的操作。

下面来看一看float数据类型都有那些常用的操作,以及和int不一样的地方:

    1.as_integer_ratio()

def as_integer_ratio(self): # real signature unknown; restored from __doc__
    """
    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

2.conjugate(self,*args,**kwargs)

def conjugate(self, *args, **kwargs): # real signature unknown
    """ Return self, the complex conjugate of any float. """

    """conjugate()返回共轭复数,高中的时候我们都学习过,共轭复数"""
    pass

  3.fromhex(self,*args,**kwargs)

def fromhex(self, string): # real signature unknown; restored from __doc__
    """
    float.fromhex(string) -> float

    Create a floating-point number from a hexadecimal string.
    >>> float.fromhex('0x1.ffffp10')
    2047.984375
    >>> float.fromhex('-0x1p-1074')
    -5e-324
    """
    return 0.0

    4.hex(self)

def hex(self): # real signature unknown; restored from __doc__
    """
    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 ""

  5.is_integer(self,*args,**kwargs)

def is_integer(self, *args, **kwargs): # real signature unknown
    """ Return True if the float is an integer. """

"""判断一个浮点型数据是否是整型的(即小数部分为零)"""
    pass

  实例如下:

>>> a = 3.0
  >>> b = 5.9
  >>> a.is_integer()
  True
  >>> b.is_integer()
  False
    我们定义了两个数3.0和5.9,其中3.0是满足is_integer的,5.9不满足返回布尔值False.

    6.__abs__(self,*args,**kwargs)

def __abs__(self, *args, **kwargs): # real signature unknown
    """ abs(self) """

"""返回一个数的绝对值"""
    pass

    实例如下:

>>> a = -3.59
  >>> b = -3
  >>> a.__abs__()
  3.59
  >>> b.__abs__()
  3

  7.__add__(self,*args,**kwargs)

def __add__(self, *args, **kwargs): # real signature unknown
    """ Return self+value. """

"""两个数相加"""
    pass

    8.__setformat__(self,typestr,fmt)

def __setformat__(self, typestr, fmt): # real signature unknown; restored from __doc__
    """
    float.__setformat__(typestr, fmt) -> None

    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'. fmt must be one of 'unknown',
    'IEEE, big-endian' or 'IEEE, little-endian', and in addition can only be
    one of the latter two if it appears to match the underlying C reality.

    Override the automatic determination of C-level floating point type.
    This affects how floats are converted to and from binary strings.
    """
    pass

float数据类型的更多相关文章

  1. 数据库中慎用float数据类型(转载)

    数据库中慎用float数据类型   大多数编程语言都支持float或者double的数据类型.而数据库中也有相同关键字的数据类型,因此很多开发人员也自然而然地在需要浮点数的地方使用float作为字段类 ...

  2. mysql进阶(十)不靠谱的FLOAT数据类型

    今天在设计数据表时,突然发现原来FLOAT原来是很不靠谱的,所以在这里建议大家换成DOUBLE类型, 原因是: 在mysql手册中讲到,在MySQL中的所有计算都是使用双精度完成的,使用float(单 ...

  3. float数据类型研究,发现其能显示的有效数字极为有限

    1. 范围  float和double的范围是由指数的位数来决定的.  float的指数位有8位,而double的指数位有11位,分布如下:  float:  1bit(符号位) 8bits(指数位) ...

  4. 将float数据类型转换为str

    示例程序: #include <stdio.h> . . void UART_send_byte(char dat); void UART_send_string(unsigned cha ...

  5. SQL中的real、float、decimal、numeric数据类型区别

    概述: 浮点数据类型包括real型.float型.decimal型和numeric型.浮点数据类型用于存储十进制小数. 在SQL Server 中浮点数值的数据采用上舍入(Round up)的方式进行 ...

  6. Sql Server之数据类型详解

      数据类型是一种属性,用于指定对象可保存的数据的类型,SQL Server中支持多种数据类型,包括字符类型.数值类型以及日期类型等.数据类型相当于一个容器,容器的大小决定了装的东西的多少,将数据分为 ...

  7. Sql Server中常见的数据类型

    转至http://www.cnblogs.com/andy_tigger/archive/2011/08/21/2147745.html bit    整型 bit数据类型是整型,其值只能是0.1或空 ...

  8. SQLServer之数据类型

    1.整数数据类型整数数据类型是常用的数据类型之一,主要用于存储数值,可以直接进行数据运算而不必使用函数转换.(1).bigint 每个bigint存储在8个字节中,其中一个二进制位表示符号位,其它63 ...

  9. 数据库中字段类型对应的C#中的数据类型

    数据库中字段类型对应C#中的数据类型: 数据库                 C#程序 int int32 text string bigint int64 binary System.Byte[] ...

随机推荐

  1. tableau学习

    一.维度 度量 1. 连接到新数据源时,Tableau 会将该数据源中的每个字段分配给“数据”窗格的“维度”区域或“度量”区域,具体情况视字段包含的数据类型而定. 例如: 2. tableau中的字段 ...

  2. 协程-遇到I/O自动切换

    参考博客:http://www.cnblogs.com/alex3714/articles/5248247.html 一.前言 Gevent 是一个第三方库,可以轻松通过gevent实现并发同步或异步 ...

  3. 第3章-Vue.js 指令扩展 和 todoList练习

    一.学习目标 了解Vue.js指令的实现原理 理解v-model指令的高级用法 能够使用Vue.js 指令完成 todoList 练习(重点+难点) 二.todoList练习效果展示 2.1.效果图展 ...

  4. 不管谁坐了CIO的位置 都必须了解的法则

    目前一些设立了CIO岗位的央企中,CIO也只做到了“IO”(信息官,Information Officer),而没有做到“C”(首席,Chief).老总们总在抱怨没有合适的人选:懂技术的不懂业务,懂业 ...

  5. ② 设计模式的艺术-02.简单工厂(Simple Factory)模式

    工厂模式 实现了创建者和调用者的分离. 详细分类:简单工厂模式.工厂方法模式.抽象工厂模式 面向对象设计的基本原则 OCP(开闭原则,Open-Closed Principle):一个软件的实体应当对 ...

  6. NYOJ 202 红黑树 (二叉树)

    题目链接 描述 什么是红黑树呢?顾名思义,跟枣树类似,红黑树是一种叶子是黑色果子是红色的树... 当然,这个是我说的... <算法导论>上可不是这么说的: 如果一个二叉查找树满足下面的红黑 ...

  7. 蓝色简单的cms文档管理系统模板——后台

    链接:http://pan.baidu.com/s/1qYMwHis 密码:xyiw

  8. nginx 配置代理某个路径

    location /test{ proxy_pass http://localhost:8765/test; proxy_set_header Host $http_host; } 其中红色的那句可以 ...

  9. 深入理解Spring系列之八:常用的扩展接口

    转载 https://mp.weixin.qq.com/s/XfhZltSlTall8wKwV_7fKg Spring不仅提供了一个进行快速开发的基础框架,而且还提供了很多可扩展的接口,用于满足一些额 ...

  10. 【zTree】zTree的3.5.26静态树与动态树(实用)

    1.静态树: 目录结构:(css与js为下载的原文件夹)