Thread Subject: greater than works better than equal to ???

Subject: greater than works better than equal to ???

From: Amitabh Verma

Date: 11 Nov, 2009 21:20:23

Message: 1 of 4

I didn't get it why >79 works better than ==80. Any thoughts ?

Thanks

Subject: greater than works better than equal to ???

From: Nathan

Date: 11 Nov, 2009 21:25:37

Message: 2 of 4

On Nov 11, 1:20 pm, "Amitabh Verma" <amt...@gmail.com> wrote:
> I didn't get it why >79 works better than ==80. Any thoughts ?
>
> Thanks

Well, in what instance?
If you are trying to find an integer value equal to 80, I would assume
that == is better than >
If you are trying to find an integer value above a specific value, >
definitely works better than ==

In cases of floating point numbers, == is rarely used due to round-off
errors. In these cases, usually the difference of two compared numbers
is then compared (using less than or greater than) to a small error-
margin number (such as eps).


What do you mean by your statement?

-Nathan

Subject: greater than works better than equal to ???

From: Matt

Date: 11 Nov, 2009 21:29:04

Message: 3 of 4

"Amitabh Verma" <amtukv@gmail.com> wrote in message <hdf9qn$c69$1@fred.mathworks.com>...
> I didn't get it why >79 works better than ==80. Any thoughts ?

It doesn't work better. It doesn't even have the same function.

Subject: greater than works better than equal to ???

From: Matt Fig

Date: 11 Nov, 2009 21:31:24

Message: 4 of 4

"Amitabh Verma" <amtukv@gmail.com> wrote in message <hdf9qn$c69$1@fred.mathworks.com>...
> I didn't get it why >79 works better than ==80. Any thoughts ?
>


My first thought is that you are comparing floating points for exact equality, which always comes with a word of caution.

80 == (80 + .03 - .01 - .01 - .01) % Equal or not?


http://matlabwiki.mathworks.com/MATLAB_FAQ#Why_is_0.3-0.2-0.1_not_equal_to_zero_.28or_similar.29.3F

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
faq_6point1 Matt Fig 11 Nov, 2009 16:30:49
rssFeed for this Thread

Contact us at files@mathworks.com