From: Avengeline on
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
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
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
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
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?
>
> --
 |  Next  |  Last
Pages: 1 2
Prev: Binary integer programming
Next: read struct