• fix


    rounds the elements of A toward zero, resulting in an array of integers. For complex A, the imaginary and real parts are rounded independently.

    将 A 的元素舍入为零, 从而生成整数数组。对于复数的 A, 实部和虚部是独立地四舍五入。

    a = [-1.9, -0.2, 3.4, 5.6, 7.0, 2.4+3.6i]
    
    a =
      Columns 1 through 4 
      -1.9000        -0.2000        3.4000        5.6000          
    
      Columns 5 through 6 
       7.0000        2.4000 + 3.6000i
    
    fix(a)
    
    ans =
      Columns 1 through 4 
      -1.0000        0             3.0000        5.0000          
    
      Columns 5 through 6 
       7.0000        2.0000 + 3.0000i

    1)fix(n)的意义是取小于n的整数(是向零点舍入的意思是往零的方向上靠),这是一类应用在整数取值上的函数,就如同以前我们所研究的求整问题,
    例如,fix(pi)=3;fix(3.5)=3;fix(-3.5)=-3;我这样举例的意思是说明这与四舍五入无关,就是纯粹的一种取值函数。下面讲到各类时我都会举例子,注意区分!

    2)round(n)的意思是纯粹的四舍五入,意思与我们以前数学中的四舍五入是一样的!
    round(pi)=3;round(3.5)=4;round(-3.5)=-4;round(-3.1)=-3;这一点注意与fix所产生的不同,注意区分!

    3)ceil(n)的意思是向正方向舍入,这一点要与floor(n)向负方向舍入一起讲,能够更好的区分,举例说明吧

    ceil(pi)=4; ceil(3.5)=4; ceil(-3.2)=-3;向正方向舍入

    floor(pi)=3; floor(3.5)=3; floor(-3.2)=-4;向负方向舍入
  • 相关阅读:
    python中的编码问题
    CVPR2018 Tutorial 之 Visual Recognition and Beyond
    hdu 1376 Octal Fractions
    hdu 1329 Hanoi Tower Troubles Again!
    hdu 1309 Loansome Car Buyer
    hdu 1333 Smith Numbers
    hdu 1288 Hat's Tea
    hdu 1284 钱币兑换问题
    hdu 1275 两车追及或相遇问题
    hdu 1270 小希的数表
  • 原文地址:https://www.cnblogs.com/xiaoxuesheng993/p/7465956.html
Copyright © 2020-2023  润新知