【 MATLAB 】eps (浮点相对精度)简介

举报
李锐博恩 发表于 2021/07/15 05:50:36 2021/07/15
【摘要】 目录   eps Syntax Description Accuracy in Double Precision Accuracy in Single Precision eps Floating-point relative accuracy Syntax d = eps d = eps(x) d = eps(datatype) ...

目录

 

eps

Syntax

Description

Accuracy in Double Precision

Accuracy in Single Precision


eps

Floating-point relative accuracy



Syntax

d = eps

d = eps(x)

d = eps(datatype)



Description

d = eps returns the distance from 1.0 to the next larger double-precision number, that is, 2^{-52}.

d = eps返回从1.0到下一个更大的双精度数的距离,即2^{-52}

d = eps(x), where x has data type single or double, returns the positive distance from abs(x) to the next larger floating-point number of the same precision as x. If x has typeduration, then eps(x) returns the next larger duration value. The command eps(1.0) is equivalent to eps.

d = eps(x),其中x具有数据类型single或double,返回从abs(x)到下一个与x相同精度的较大浮点数的正距离。 如果x具有typeduration,则eps(x)返回下一个更大的持续时间值。 命令eps(1.0)等同于eps。

d = eps(datatype) returns eps according to the data type specified by datatype, which can be either 'double' or 'single'. The syntax eps('double') (default) is equivalent to eps, and eps('single') is equivalent to eps(single(1.0)).

d = eps(datatype)根据datatype指定的数据类型返回eps,数据类型可以是“double”或“single”。 语法eps('double')(默认)等同于eps,eps('single')等同于eps(single(1.0))。



Accuracy in Double Precision


  
  1. clc
  2. clear
  3. close all
  4. % Display the distance from 1.0 to the next largest double-precision number.
  5. d = eps
  6. % d = 2.2204e-16
  7. % eps is equivalent to eps(1.0) and eps('double').
  8. % Compute log2(eps).
  9. d = log2(eps)
  10. % d = -52
  11. % In base 2, eps is equal to 2^-52.
  12. %
  13. % Find the distance from 10.0 to the next largest double-precision number.
  14. d = eps(10.0)
  15. % d = 1.7764e-15

结果如下:

d =

   2.2204e-16


d =

   -52


d =

   1.7764e-15

 

Accuracy in Single Precision


  
  1. clc
  2. clear
  3. close all
  4. % Display the distance from 1.0 to the next largest single-precision number.
  5. d = eps('single')
  6. % d = single
  7. % 1.1921e-07
  8. % eps('single') is equivalent to eps(single(1.0)).
  9. % Compute log2(eps('single')).
  10. d = log2(eps('single'))
  11. % d = single
  12. % -23
  13. % In base 2, single-precision eps is equal to 2^-23.
  14. % Find the distance from the single-precision representation of 10.0 to the next largest single-precision number.
  15. d = eps(single(10.0))
  16. % d = single
  17. % 9.5367e-07

结果如下:

d =

  single

  1.1921e-07


d =

  single

   -23


d =

  single

  9.5367e-07

 

 

 

 

文章来源: reborn.blog.csdn.net,作者:李锐博恩,版权归原作者所有,如需转载,请联系作者。

原文链接:reborn.blog.csdn.net/article/details/83066384

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。