Prev: Binary integer programming
Next: read struct
From: Avengeline on 4 Feb 2010 20:33 I have 2 values of: e = 98; f = 77; f - e should be equals to -21, but MATLAB says its 0. Can anyone help? A photo of the problem is attached here: http://farm5.static.flickr.com/4031/4331616010_c941b62a0f_b.jpg
From: Walter Roberson on 4 Feb 2010 20:51 Avengeline wrote: > I have 2 values of: > > e = 98; > f = 77; > > f - e should be equals to -21, but MATLAB says its 0. Can anyone help? The values are probably one of the unsigned integer types.
From: dpb on 4 Feb 2010 20:54 Avengeline wrote: > I have 2 values of: > > e = 98; > f = 77; > > f - e should be equals to -21, but MATLAB says its 0. Can anyone help? > > A photo of the problem is attached here: > > http://farm5.static.flickr.com/4031/4331616010_c941b62a0f_b.jpg Well, the variable editor indicates e is an uint8 which means if f is also the result would also be unsigned which would underflow. What does double(f)-double(e) return? --
From: Avengeline on 4 Feb 2010 20:58 Walter Roberson <roberson(a)hushmail.com> wrote in message <hkftiv$r3f$1(a)canopus.cc.umanitoba.ca>... > Avengeline wrote: > > I have 2 values of: > > > > e = 98; > > f = 77; > > > > f - e should be equals to -21, but MATLAB says its 0. Can anyone help? > > The values are probably one of the unsigned integer types. How should I fix this?
From: Avengeline on 4 Feb 2010 21:29
dpb <none(a)non.net> wrote in message <hkftqn$hlk$1(a)news.eternal-september.org>... > Avengeline wrote: > > I have 2 values of: > > > > e = 98; > > f = 77; > > > > f - e should be equals to -21, but MATLAB says its 0. Can anyone help? > > > > A photo of the problem is attached here: > > > > http://farm5.static.flickr.com/4031/4331616010_c941b62a0f_b.jpg > > Well, the variable editor indicates e is an uint8 which means if f is > also the result would also be unsigned which would underflow. > > What does > > double(f)-double(e) > Thanks. I have changed to a = f - e; a = int8(a); > return? > > -- |