Programming Nerdfest

Programming Nerdfest

PostBy: 009to090 On: Wed Feb 25, 2009 11:43 am

Richard S. wrote: (For you non-nerds != literally means does not equal).



Hi Richard, I've been programming for 30 years. Never saw an example of != meaning Does-not-Equal. What language is that?
I usually use ^= or for Does-not-equal.
009to090
 
Stoker Coal Boiler: EFM 520 HighBoy
Hot Air Coal Stoker Stove: DVC-500 x 2
Coal Size/Type: Anthracite Rice

Re: Programming Nerdfest

PostBy: Richard S. On: Wed Feb 25, 2009 1:15 pm

I split this post as I can foresee this going way off topic of the original. I should clarify it won't set a variable but instead is used for comparison. It's used in PHP and used quite extensively mostly for comparison or determining if something is false.

http://us3.php.net/manual/en/language.o ... arison.php


Comparison:
Code: Select all

$var1 
= '1';
$var2 = '2';

if ($var1 != $var2)
{
//code will execute because $var1 and $vaqr2 are not equal. 
}
 




Code: Select all

if 
(!$var)
{
//code will execute if the variable is not set
}
 

Reversing a function:

Code: Select all

$var 
= 'abcd';

if (!is_numeric($var))
{
//code will  execute because its not a number
}
  




I'm only familiar with PHP, it's my understanding it's a much less strict language than others so that is probably why it's not used elsewhere. There's probably about a hundred different ways you could write the above but those would be almost the shortest AFAIK. As you can see it can be very useful. In PHP you can shorten comparisons even further using the ?

Code: Select all

$var 
= 'abcd';

echo (!is_numeric($var) ? 'is not numbers' : 'is numbers');
 


This will of course echo "is not numbers" :P
Richard S.
 
Stoker Coal Boiler: Van Wert VA1200
Coal Size/Type: Buckwheat/Anthracite

Re: Programming Nerdfest

PostBy: 009to090 On: Wed Feb 25, 2009 2:49 pm

Ah, ok. Thanks for the explanation and examples. I am familiar with the logic in the examples you include, but never saw the != syntax from PHP before. It appears PHP is very similar to SAS or BASIC in coding logic and syntax.

Thanks!
009to090
 
Stoker Coal Boiler: EFM 520 HighBoy
Hot Air Coal Stoker Stove: DVC-500 x 2
Coal Size/Type: Anthracite Rice


Re: Programming Nerdfest

PostBy: Richard S. On: Wed Feb 25, 2009 2:56 pm

FYI you can get the highlighting by adding =php to the bbcode tag, assuming the syntax is the same it should work pretty well for most laguages:

Code: Select all
[code=php] Some code[/code]
Richard S.
 
Stoker Coal Boiler: Van Wert VA1200
Coal Size/Type: Buckwheat/Anthracite

Re: Programming Nerdfest

PostBy: pvolcko On: Wed Feb 25, 2009 5:29 pm

!= is used in Java, C/C++, php, some shell scripting languages, and a number of other languages for not-equals logical comparisons.

In C/C++ I think ^= will actually perform a bitwise xor operation on the left side var (and assign result back) with the right side var. :)
pvolcko
 

Re: Programming Nerdfest

PostBy: Don_t_Say On: Wed Feb 25, 2009 11:00 pm

I thought you guys who could write "code" could pay any price for fuel. Why are you burning coal? :)
Don_t_Say
 
Stove/Furnace Make: Hitzer
Stove/Furnace Model: 50-93

Re: Programming Nerdfest

PostBy: 009to090 On: Wed Feb 25, 2009 11:17 pm

Don_t_Say wrote:I thought you guys who could write "code" could pay any price for fuel. Why are you burning coal? :)



I got layed off Oct 1st, and am still lookin' for a job. But we ordered the DVC-500 last May, so when it finally arrived in Jan, I went ahead and installed it. Glad I did. Now all I need to do is find a job to keep the house :fear:
009to090
 
Stoker Coal Boiler: EFM 520 HighBoy
Hot Air Coal Stoker Stove: DVC-500 x 2
Coal Size/Type: Anthracite Rice

Re: Programming Nerdfest

PostBy: AdkCoal On: Wed Feb 25, 2009 11:32 pm

I write code for a living but I refuse to send my hard earned cash to the Arabs.

Would rather my dollars go to some American workers.
AdkCoal
 
Stove/Furnace Make: Keystoker
Stove/Furnace Model: KAA-2

Re: Programming Nerdfest

PostBy: Richard S. On: Wed Feb 25, 2009 11:50 pm

Richard S.
 
Stoker Coal Boiler: Van Wert VA1200
Coal Size/Type: Buckwheat/Anthracite

Re: Programming Nerdfest

PostBy: 009to090 On: Thu Feb 26, 2009 9:01 am

FREE lessons! That matches my budget! :D

Thanks!

Goes to show, your never too old to learn new tricks... My dog is, but not I !!! :D :D
009to090
 
Stoker Coal Boiler: EFM 520 HighBoy
Hot Air Coal Stoker Stove: DVC-500 x 2
Coal Size/Type: Anthracite Rice

Re: Programming Nerdfest

PostBy: Richard S. On: Thu Feb 26, 2009 9:15 am

The php manual is particularly helpful on the programming side, it's in forum like format. They provide the official explanation at the top but down below that is the hidden gems with user provided examples. If you take my link from above for the != there about 15 examples below the official explantion with that other operator examples. The whole manual is like that. There's downloadable version too.
Richard S.
 
Stoker Coal Boiler: Van Wert VA1200
Coal Size/Type: Buckwheat/Anthracite