Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Not Equal to ( =! )

Author
Message
Derekioh
16
Years of Service
User Offline
Joined: 1st Feb 2009
Location:
Posted: 27th Jun 2010 23:18
I know this is a stupid question, but does DB Pro have a not equal to symbol or something, such as =!

Link102
20
Years of Service
User Offline
Joined: 1st Dec 2004
Location: On your head, weeeeee!
Posted: 27th Jun 2010 23:20
1 <> 0

Brendy boy
19
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 28th Jun 2010 03:05
ShaunRW
DBPro Developer
17
Years of Service
User Offline
Joined: 7th Jan 2008
Location: Brisbane, Australia
Posted: 28th Jun 2010 06:15
Link102 is correct, use <>.

sneaky smith12
19
Years of Service
User Offline
Joined: 30th Apr 2006
Location: Like id tell you, oh wait i just did
Posted: 28th Jun 2010 07:07 Edited at: 28th Jun 2010 07:51
Basic Syntax <> C++ Syntax

EDIT:

I know I just made a funny for those whom understand; however, I figured I'd explain the logical differences.

<> equates to "less than or greater than"
=! equates to "Not equal"

Let's say we have variable p and variable q, and they are different, where one value is while the other is not.

It could be expressed as (p . ~q) (or, "p and not q") for basic syntax, or it could be expressed as ~p (or, "Not p") for c++ syntax. By definition of the phrase "p and not q" for the conditional statement to be true p MUST be true and q MUST be false. By definition of "Not p" p MUST be false.

Granted based on logical principles you can change the need for the not equals by changing how it's coded:



is the same as



So this being said it makes sense that basic (or, "Beginner's All-purpose Symbolic Instruction Code) uses the "<>" because it immediately and exclusively infers a comparison. The syntax for c++ only identifies a negation.

If this explanation goes over your head I would suggest taking a introductory logic class (I did that, and found it fascinating... granted I'm actually in college) or just read about Sentential Logic.

If at first you dont succeed, LOWER YOUR STANDARDS.
Flatlander
FPSC Tool Maker
18
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 28th Jun 2010 07:19
Quote: "Basic Syntax <> C++ Syntax"




Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 28th Jun 2010 16:00
Just a quick query, what is the difference between...

=!

and

!=

Do they do the same thing? - I've been using <> in C++ with integers, guess I should investigate some actual C++ syntax!, it's bad enough that I keep forgetting ;'s and double '='s .


Health, Ammo, and bacon and eggs!
Benjamin
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 28th Jun 2010 18:23
Quote: "Just a quick query, what is the difference between...

=!

and

!="


The former will invert (if integer or boolean) the variable, whereas the latter is the comparison operator.
Dark Dragon
17
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 28th Jun 2010 18:38
Quote: "The former will invert (if integer or boolean) the variable"



Does that work in pro? Could be useful.

sneaky smith12
19
Years of Service
User Offline
Joined: 30th Apr 2006
Location: Like id tell you, oh wait i just did
Posted: 28th Jun 2010 18:49 Edited at: 28th Jun 2010 18:52
@dark dragon:

Type in the word "not" and watch it change pretty colors
The same is true for "and", "or" and "xor".

Granted not doesn't make the opposite as much as look for anything but the value.

If at first you dont succeed, LOWER YOUR STANDARDS.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 28th Jun 2010 18:58
I see Benjamin, thanks for clearing that up.

I find the quickest way to invert in DBPro is...

1-v

If v is 0 it becomes 1, if it's 1 then it becomes 0. If that's what your talking about.


Health, Ammo, and bacon and eggs!
Diggsey
19
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 28th Jun 2010 19:01
Yeah, 'not' in DBPro does a binary not, so 'not 1' becomes 0xFFFFFFFE UNLESS it is immediately after an 'if' statement:
if not 1
print "Never here"
else
print "Always here"
endif

When it does a logical 'not'

Login to post a reply

Server time is: 2025-05-28 03:43:00
Your offset time is: 2025-05-28 03:43:00