Cannot subtract number of order smaller then e-4 from variable
    6 次查看(过去 30 天)
  
       显示 更早的评论
    
a=0.1; a=a-1e-5 gives result a=0.1000
0 个评论
采纳的回答
  Torsten
      
      
 2024-11-26
        
      编辑:Torsten
      
      
 2024-11-26
  
      It's just a question of how the numbers are displayed. 
Internally, the precision of computing is much higher.
format long  % Use display format long
a = 0.1;
a = a - 1e-5
format short
a
3 个评论
  Walter Roberson
      
      
 2024-11-26
				
      编辑:Walter Roberson
      
      
 2024-11-26
  
			format long  % Use display format long
a = 0.1;
fprintf('%.999g\n', a)
a = a - 1e-5
fprintf('%.999g\n', a)
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


