Matlab/Octave相加,失去精度 [英] Matlab/Octave addition, losing digits of precision

查看:111
本文介绍了Matlab/Octave相加,失去精度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Matlab/八度音阶中,当我将两个数字相加时,会丢失一些数字.

In Matlab/octave, when I add two numbers, I am losing some of my digits.

>>> 23.0 + 0.65850
ans =  23.659

如何获取23.65850的双精度值?

推荐答案

数字仅出于显示目的四舍五入.如果要更改format命令,请查看它.

The number is being rounded only for display purposes. Take a look at the format command if you wish to change it.

octave> 23 + 0.65850
ans =  23.659
octave> format free
octave> 23 + 0.65850
ans = 23.7
octave> format long g
octave> 23 + 0.65850
ans =              23.6585

看看help format的其他选项,但请记住,此 only 会影响显示.您不会失去任何精度.

Take a look at help format for the other options but remember, that this only affects the display. You are not losing any precision.

这篇关于Matlab/Octave相加,失去精度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆