Code Comments
Programming Forum and web based access to our favorite programming groups.Hi, I'm having the following problem with fortran 90 using logical operators. With the following statement I get the right answer. The statement is as follows: if(x_cor_split(j).eq.x_cor_split(repetidos(i,2)).and.& y_cor_split(j).eq.y_cor_split(repetidos(i,2))) then ... Now, I need to obtain exactly the opposite answer, so I suppose that I just need to change the lo .eq. by .ne., but when I change the lo, I get a totally different answer of what I was expecting for. How can I solve this problem? FYI I'm using cvf 6.6 Hope somebody can help me, Greetings, Joel
Post Follow-up to this messageOn 19 Oct 2004 20:22:29 -0700, joel GUERRERO wrote: > Hi, > I'm having the following problem with fortran 90 using logical > operators. > With the following statement I get the right answer. The statement is > as follows: > if(x_cor_split(j).eq.x_cor_split(repetidos(i,2)).and.& > y_cor_split(j).eq.y_cor_split(repetidos(i,2))) then ... > Now, I need to obtain exactly the opposite answer, so I suppose that I > just need to change the lo .eq. by .ne., but when I change the lo, I > get a totally different answer of what I was expecting for. How can I > solve this problem? The negation of (1) (a .eq. b) .and. (c .eq. d) is which of the following? (pick one:) (2) (a .ne. b) .and. (c .ne. d) (3) (a .ne. b) .or. (c .ne. d) > FYI I'm using cvf 6.6 Makes no difference. -- Dave Seaman Judge Yohn's mistakes revealed in Mumia Abu-Jamal ruling. <http://www.commoncouragepress.com/i...book&bookid=228>
Post Follow-up to this messageDave Seaman wrote: > > On 19 Oct 2004 20:22:29 -0700, joel GUERRERO wrote: > > > The negation of > > (1) (a .eq. b) .and. (c .eq. d) > > is which of the following? (pick one:) > > (2) (a .ne. b) .and. (c .ne. d) > (3) (a .ne. b) .or. (c .ne. d) > > > Makes no difference. > The logical negation of (1) is (3). It is a rather elementary exercise in logic :) Regards, Arjen
Post Follow-up to this messageDave Seaman wrote: > On 19 Oct 2004 20:22:29 -0700, joel GUERRERO wrote: > > > > > > The negation of > > (1) (a .eq. b) .and. (c .eq. d) > > is which of the following? (pick one:) > > (2) (a .ne. b) .and. (c .ne. d) > (3) (a .ne. b) .or. (c .ne. d) or (4) .not. ((a .eq. b) .and. (c .eq. d))
Post Follow-up to this messagejoel GUERRERO wrote: > > Now, I need to obtain exactly the opposite answer, so I suppose that I > just need to change the lo .eq. by .ne., but when I change the lo, I > get a totally different answer of what I was expecting for. How can I > solve this problem? Enroll in the appropriate course, or consult a textbook on "Boolean algebra". In the meantime, short answer is: .not.(expr)
Post Follow-up to this messageOn Wed, 20 Oct 2004 at 06:24 GMT, Tom Micevski (aka Bruce) was almost, but not quite, entirely unlike tea: > Dave Seaman wrote: > or > (4) .not. ((a .eq. b) .and. (c .eq. d)) Which the compiler ought to optimise to the quickest to evaluate expression anyway, so use the expression that makes most sense in the context. Sometimes refactoring complex boolean expressions makes me realise I was thinking about it the hard way when I came up with with the original expression. -- TimC -- http://astronomy.swin.edu.au/staff/tconnors/ Disclaimer: This post owned by the owner
Post Follow-up to this messageHi, http://mathworld.wolfram.com/deMorgansLaws.html Regards, B52B joel GUERRERO wrote: > Hi, > I'm having the following problem with fortran 90 using logical > operators. > With the following statement I get the right answer. The statement is > as follows: > if(x_cor_split(j).eq.x_cor_split(repetidos(i,2)).and.& > y_cor_split(j).eq.y_cor_split(repetidos(i,2))) then ... > > Now, I need to obtain exactly the opposite answer, so I suppose that I > just need to change the lo .eq. by .ne., but when I change the lo, I > get a totally different answer of what I was expecting for. How can I > solve this problem? > > FYI I'm using cvf 6.6 > > Hope somebody can help me, > > Greetings, > Joel
Post Follow-up to this message"joel GUERRERO" <joegi.geo@yahoo.com> wrote in message news:bc7de858.0410191922.2f7cd7d1@posting.google.com... > Hi, > I'm having the following problem with fortran 90 using logical > operators. > With the following statement I get the right answer. The statement is > as follows: > if(x_cor_split(j).eq.x_cor_split(repetidos(i,2)).and.& > y_cor_split(j).eq.y_cor_split(repetidos(i,2))) then ... > > Now, I need to obtain exactly the opposite answer, so I suppose that I > just need to change the lo .eq. by .ne., but when I change the lo, I > get a totally different answer of what I was expecting for. How can I > solve this problem? > > FYI I'm using cvf 6.6 > > Hope somebody can help me, > > Greetings, > Joel As an extra comment : If x_cor_split and/or y_cor_split are floating point numbers, it is not recommended to be testing for equality, or non-equality, but within some tolerance. Les
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.