Author Topic: [Atmel studio] won't accept !==  (Read 4976 times)

0 Members and 1 Guest are viewing this topic.

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14230
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
[Atmel studio] won't accept !==
« on: July 10, 2018, 01:30:56 pm »
if (ADC_array_position !== ADC_array_end)

The compiler fails saying that there is nothing before "="
https://www.simonselectronics.co.uk/shop
Varied stock of test instruments and components including EEVblog gear and Wurth Elektronik Books.
Also, if you want to get ripped off: https://www.ebay.co.uk/usr/simons_electronics?_trksid=p2047675.l2559
 

Offline ljwinkler

  • Supporter
  • ****
  • Posts: 48
  • Country: ie
    • LJ Winkler's blog
Re: [Atmel studio] won't accept !==
« Reply #1 on: July 10, 2018, 01:32:54 pm »
You can't have !==.  It's either != (not equal to) or == (equal to) :)

Offline Fred27

  • Supporter
  • ****
  • Posts: 564
  • Country: gb
    • Fred's blog
Re: [Atmel studio] won't accept !==
« Reply #2 on: July 10, 2018, 01:33:54 pm »
You would happen to be a JavaScript developer, would you?
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14230
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: [Atmel studio] won't accept !==
« Reply #3 on: July 10, 2018, 02:20:04 pm »
You would happen to be a JavaScript developer, would you?

Nope, apart from a short foray into BASIC  it has been C all the way.

== is to test one thing is equal to another, I was just making the assumption that I could invert it. presumably != is a dedicated "not equal to" operator.
https://www.simonselectronics.co.uk/shop
Varied stock of test instruments and components including EEVblog gear and Wurth Elektronik Books.
Also, if you want to get ripped off: https://www.ebay.co.uk/usr/simons_electronics?_trksid=p2047675.l2559
 

Online wraper

  • Supporter
  • ****
  • Posts: 10765
  • Country: lv
Re: [Atmel studio] won't accept !==
« Reply #4 on: July 10, 2018, 02:22:52 pm »
You would happen to be a JavaScript developer, would you?

Nope, apart from a short foray into BASIC  it has been C all the way.

== is to test one thing is equal to another, I was just making the assumption that I could invert it. presumably != is a dedicated "not equal to" operator.
I find it very strange that you never used != before.
 

Offline ljwinkler

  • Supporter
  • ****
  • Posts: 48
  • Country: ie
    • LJ Winkler's blog
Re: [Atmel studio] won't accept !==
« Reply #5 on: July 10, 2018, 02:24:01 pm »
In this case you could use:  if !(ADC_array_position == ADC_array_end)

Offline mbless

  • Regular Contributor
  • *
  • Posts: 191
  • Country: 00
Re: [Atmel studio] won't accept !==
« Reply #6 on: July 10, 2018, 02:42:43 pm »
It's just like >= and <=. There's only 2 symbols.
 

Online JPortici

  • Super Contributor
  • ***
  • Posts: 2568
  • Country: it
Re: [Atmel studio] won't accept !==
« Reply #7 on: July 10, 2018, 03:47:20 pm »
You would happen to be a JavaScript developer, would you?

Nope, apart from a short foray into BASIC  it has been C all the way.

== is to test one thing is equal to another, I was just making the assumption that I could invert it. presumably != is a dedicated "not equal to" operator.
I find it very strange that you never used != before.

same. i can see you logic, but in C logical operators are either one or two symbols.

if i may.. i suppose "ADC_array_end" is something like "size of array".. like if you declare array[16] then ADC_array_end=15.

if this is the case i suggest you use either
Code: [Select]
#define ADC_ARRAY_SIZE 16

int ADC_array[ADC_ARRAY_SIZE];

...

if (ADC_array_position >= ADC_ARRAY_SIZE) {
 ..
}

..

or
Code: [Select]
int ADC_Array[16];
int ADC_Array_End = 15;

..

if (ADC_array_position  > ADC_Array_End) {
  ..
}

..

for the unlikely (but very possible) situation where you increment ADC_array_position , but for some reason it skips ADC_array_end
 

Offline Sal Ammoniac

  • Frequent Contributor
  • **
  • Posts: 950
  • Country: us
    • Embedded Tales Blog
Re: [Atmel studio] won't accept !==
« Reply #8 on: July 10, 2018, 04:05:59 pm »
In this case you could use:  if !(ADC_array_position == ADC_array_end)

That won't work either. This does:  if (!(ADC_array_position == ADC_array_end))
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 10523
  • Country: us
Re: [Atmel studio] won't accept !==
« Reply #9 on: July 10, 2018, 04:15:22 pm »
!= is a very common operator used in quite a few languages to indicate inequality. It surprises me to hear someone got past the "Hello World" stage without encountering it. I have yet to encounter a 3-character operator.
 

Offline ejeffrey

  • Super Contributor
  • ***
  • Posts: 2037
  • Country: us
Re: [Atmel studio] won't accept !==
« Reply #10 on: July 10, 2018, 04:23:20 pm »
Nope, apart from a short foray into BASIC  it has been C all the way.

== is to test one thing is equal to another, I was just making the assumption that I could invert it. presumably != is a dedicated "not equal to" operator.

In C (and most languages) you don't ever invert operators, only values.  You can't do something like !< or !>= either.  != is a separate operator from == that has the opposite value, but one isn't defined in terms of the other.

Someone asked about javascript because javascript has two "equality" comparison operators, == and ===.  So those two operators have inverses that are != and !==.  Again these are not syntactically created by applying inverse to the == and === operators, they are operators in their own right.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 14230
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: [Atmel studio] won't accept !==
« Reply #11 on: July 10, 2018, 05:25:14 pm »
Nope, i have never had to use != before. I am now using ">" anyway, the problem was the last one in many i was looking at in writing some new code to run a project in a very different way to how I normally do it.
https://www.simonselectronics.co.uk/shop
Varied stock of test instruments and components including EEVblog gear and Wurth Elektronik Books.
Also, if you want to get ripped off: https://www.ebay.co.uk/usr/simons_electronics?_trksid=p2047675.l2559
 

Offline exit_failure

  • Regular Contributor
  • *
  • Posts: 66
  • Country: de
Re: [Atmel studio] won't accept !==
« Reply #12 on: July 10, 2018, 06:13:41 pm »
I have yet to encounter a 3-character operator.

In C/C++ there are the bitshift and assign operators:

<<= and >>=

Code: [Select]
a <<= 2
is the same as

Code: [Select]
a = a << 2
« Last Edit: July 10, 2018, 06:16:31 pm by exit_failure »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 3123
  • Country: us
Re: [Atmel studio] won't accept !==
« Reply #13 on: July 10, 2018, 09:09:00 pm »
Quote
I have yet to encounter a 3-character operator.
Fortran has logical operators up to 6 characters (heh.  2nd time I've had cause to mention fortran in the last couple of days.)".and.", ".not.", ".nequv."  (there are ".le." equivalents for the standard comparison operators as well)
Cobol apparently has "IF WS-NUM1 IS GREATER THAN OR EQUAL TO WS-NUM2 THEN", but since this is an EE forum, we can be excused for not ever having seen any cobol...  (and I don't think even cobol coders actually WRITE code like that.)
« Last Edit: July 10, 2018, 09:13:37 pm by westfw »
 

Offline glarsson

  • Frequent Contributor
  • **
  • Posts: 807
  • Country: se
Re: [Atmel studio] won't accept !==
« Reply #14 on: July 10, 2018, 09:27:58 pm »
In Forth one of the standard "operators" is */MOD that performs a multiply and division (with intermediate results as double precision) returning both the result of the division but also the remainder.
 
The following users thanked this post: newbrain

Offline Monkeh

  • Super Contributor
  • ***
  • Posts: 6090
  • Country: gb
Re: [Atmel studio] won't accept !==
« Reply #15 on: July 10, 2018, 10:19:57 pm »
Nope, i have never had to use != before.

Have you considered actually reading a book on C? Obtaining some form of formal programming education? ... reading basically any code in the wild?
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 10523
  • Country: us
Re: [Atmel studio] won't accept !==
« Reply #16 on: July 10, 2018, 11:01:06 pm »
Heck != is so ingrained that I see it used in casual conversation, usually by people who have some exposure to programming but not necessarily professional developers.
 
The following users thanked this post: wraper, Frank

Offline andersm

  • Super Contributor
  • ***
  • Posts: 1113
  • Country: fi
Re: [Atmel studio] won't accept !==
« Reply #17 on: July 10, 2018, 11:15:30 pm »
I have yet to encounter a 3-character operator.
In C/C++ there are the bitshift and assign operators:
<<= and >>=
C++20 will also add the three-way comparison "spaceship" operator <=>.

Offline Koen

  • Frequent Contributor
  • **
  • Posts: 488
Re: [Atmel studio] won't accept !==
« Reply #18 on: July 10, 2018, 11:21:58 pm »
 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 2455
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: [Atmel studio] won't accept !==
« Reply #19 on: July 10, 2018, 11:29:28 pm »
I have yet to encounter a 3-character operator.

Weakly typed languages (for example, PHP and Javascript) often have both "==" and "===", for example

  1 == true
  1 === true

give different results.
~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Online Cerebus

  • Super Contributor
  • ***
  • Posts: 4002
  • Country: gb
Re: [Atmel studio] won't accept !==
« Reply #20 on: July 11, 2018, 12:17:51 am »
!= is a very common operator used in quite a few languages to indicate inequality. It surprises me to hear someone got past the "Hello World" stage without encountering it. I have yet to encounter a 3-character operator.

"/:=", "divide and becomes", an assigning division operator in Algol 68 which assigns ENTIER(left/right) to left and returns the remainder of left/right as its result. So:

Code: [Select]
REF INT remainder;
REF INT left := -7;
INT right = 3;

remainder := left /:= right;

leaves:
remainder = 2
left = -3
right unchanged

And no, I never found a use for it in real life. I suspect that the motivation for the inclusion of the operation was the fact that a lot of processor architectures at the time implemented division so that the dividend and remainder ended up in two registers and they wanted an efficient way to exploit this when compilers weren't smart enough to optimise away a seperate pair of division and remainder operations into one 'divide with remainder' opcode.
Anybody got a syringe I can use to squeeze the magic smoke back into this?
 

Offline helius

  • Super Contributor
  • ***
  • Posts: 2870
  • Country: us
Re: [Atmel studio] won't accept !==
« Reply #21 on: July 11, 2018, 12:35:43 am »
!ErrorHasOccured() ??!??! HandleError();
Trigraphs are great! A lot of the IOCCC entries make heavy use of them: http://www.ioccc.org/years.html
 

Offline Leiothrix

  • Regular Contributor
  • *
  • Posts: 99
  • Country: au
Re: [Atmel studio] won't accept !==
« Reply #22 on: July 11, 2018, 02:51:34 am »
!= is a very common operator used in quite a few languages to indicate inequality. It surprises me to hear someone got past the "Hello World" stage without encountering it. I have yet to encounter a 3-character operator.

Powershell.  It doesn't use a symbol like == for equality, it uses -eq.  Powershell also has operators like -contains, -notmatch, and a pile of others.  Typical Microsoft thinking at work.
 

Offline Bassman59

  • Super Contributor
  • ***
  • Posts: 1291
  • Country: us
  • Yes, I do this for a living
Re: [Atmel studio] won't accept !==
« Reply #23 on: July 11, 2018, 03:21:37 am »
if (ADC_array_position !== ADC_array_end)

The compiler fails saying that there is nothing before "="

That’s because you’re writing C, not Verilog.

This is one of the reason why I think people who say, “If you know C, you’ll be able to pick up Verilog in no time!” Yeah, sure, despite the fact that the two languages serve different problem domains.

Here’s a fun bug that baffled me for a little bit. I was doing a project that had an 8051 talking to an FPGA. And for the micro code, I wrote something like:

Code: [Select]
if (foo /= bar) {
And wondered why it compiled, linked, but didn’t work.
 

Offline Monkeh

  • Super Contributor
  • ***
  • Posts: 6090
  • Country: gb
Re: [Atmel studio] won't accept !==
« Reply #24 on: July 11, 2018, 03:26:28 am »
!= is a very common operator used in quite a few languages to indicate inequality. It surprises me to hear someone got past the "Hello World" stage without encountering it. I have yet to encounter a 3-character operator.

Powershell.  It doesn't use a symbol like == for equality, it uses -eq. ...  Typical Microsoft thinking at work.

Typical Microsoft thinking?

-eq is an integer comparison operator which probably goes back to the early 1970s. ie. pre-Microsoft. You may find shells are a more varied world than you expect.
 
The following users thanked this post: newbrain


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf