Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Conditions

Name: Anonymous 2011-09-03 10:01

Is it not possible to use
if(0<x<10){}

or do you have to use
if(x>0&&x<10){}

?

Name: Anonymous 2011-09-03 10:01

They compile to the same

Name: Anonymous 2011-09-03 10:46

What >>2 said, but it's a good idea to put them in separate brackets, for the sake of readability.
if((x > 0) && (x < 10) {
  shit;
}

It evaluates to the exact same thing, since < and > operators have higher priority than && operator, but it looks nicer.

Name: Anonymous 2011-09-03 11:06

>>3
It evaluates to the exact same thing, since < and > operators have higher priority than && operator, but it looks nicer.

You're mixing up operator precedence with associativity. Now shut up and go clean another toilet you mental midget.

Name: Anonymous 2011-09-03 11:09

>>2
Wouldn't it always run in a language that treats true as one if x was greater than zero?

Name: Anonymous 2011-09-03 11:13

>>4
I'm not mixing it up, you fucking retard.

Name: Anonymous 2011-09-03 11:20

>>4
Yes you are dumbass. The following...

since < and > operators have higher priority than && operator

Is wrong. And if you ever told me that during an interview, you would end up getting a rejection letter basically telling you to go fuck off.

Name: Anonymous 2011-09-03 11:31

>>7
Do you need operator precedence / associativity chart to see that I'm right? Where do you see the problem?

Name: Anonymous 2011-09-03 11:35

>>7
You sound awfully self-important for a code monkey.

Name: Anonymous 2011-09-03 11:56

>>9
I help interview fools like you. Now here's some advice you homo..

a)Don't list every fucking technology that you've ever seen or worked with. Shit like that gets directed to the garbage bin.

b)Don't have a job objective that is different than what we're looking for. All this tells me, along with everyone here that you didn't take the time to read the actual job description.

c)If we don't interview you either way, it means that you suck.

d)I don't give a shit if you are a new college grad trying to get your foot in the door.

Name: Anonymous 2011-09-03 11:58

Let x = 11

0<x<10:

0<11 will be evaluated as 1 and then 1<11 will return 1.

So it depends on the language. Left or right associativity is important and if it short-circuited.

Name: Anonymous 2011-09-03 11:58

>>8
The problem is that you don't be drawing a clear distinction between the two. Now again, go run off and clean another toilet.

Name: Anonymous 2011-09-03 12:04

0<11 will be evaluated as 1 and then 1<11 will return 1.

Which language would this hold true for? For example, in Java, 0 < x is evaluated to a boolean value which cannot be compared with 10.

Left or right associativity is important and if it short-circuited.

I don't think so.

Name: Anonymous 2011-09-03 12:06

>>13
Which language would this hold true for?
C.

Name: Anonymous 2011-09-03 12:44

if (0 < x < 10) is not identically equal to if (0 < x && x < 10), one will branch more often than the other and it is probably not what you want.

Name: Anonymous 2011-09-03 13:22

>>12
Yep, you're fucking stupid.

Name: Anonymous 2011-09-03 14:13

>>16
At least I have the IQ to work as a software engineer for a major U.S firm. You never have and never will have what it takes to be a computer programmer. Now shut up and clean the girls bathroom you mental midget.

Name: Anonymous 2011-09-03 14:13

>>16
And I'm still not granting you the first interview you fucking idiot. Your resume, just like you, sucks dick.

Name: Anonymous 2011-09-03 16:45

>>13

Java? Language? Seriously, people who cannot even handle the memory should not be able to write here.

What I said is completely valid for languages which can use integers as booleans. And also, if the language is not short-circuit evaluated, what I write might become obsolete. And when you talk about short-circuit, right or left associativity does always matter.

You high schooler java fag. Take a programming languages course when you get to college.

Name: Anonymous 2011-09-03 17:09

>>19
Different guy here.
What use is there for booleans? When programs compile are they wrapped up into bits instead of each having an individual byte? (Think bitwise operators.)

Name: Anonymous 2011-09-03 18:25

>>20

Actually the only reason I can remember is safety. I can dig up my PL book if you want me to(this includes implementation details).

Name: Alpha Male !gD3Op2fhHs 2011-09-03 18:40

>>7
And if you ever told me that during an interview, you would end up getting a rejection letter basically telling you to go fuck off.
This is where you betray your omega personality to us. An alpha male would tell the incompetent candidate to fuck off personally at the interview, not through a letter. Grow some balls you fucking pussy.

Name: Anonymous 2011-09-03 18:47

>>12
The problem is that you don't be drawing a clear distinction between the two.
Guys, guys, I think we have an actual nigger here! I'm all giddy, guys!

Name: Anonymous 2011-09-03 19:14

Python and Lisp work like that, there might be other languages that I don't know about.

In most languages (like C), 0 < x will evaluate to 0 or 1, so you get 1 < 10. This is assuming that the language converts true and false to 1 or 0.

Name: Anonymous 2011-09-03 20:31

>>24
I don't want to program in a snake or in a speech impediment.

Name: Anonymous 2011-09-03 20:52

If it ain't a speech impediment, it's bogus.

Name: n3n7i 2011-09-03 21:29

My personal favourite
if((x>0)+(x<10)==2) {}

Name: Anonymous 2011-09-03 21:56

(< 0 x 10) in CL

Name: n3n7i 2011-09-03 22:34

...Is that something?

was trying to think of a good 2 out of 3 state example...

Hows this

if((x%2==0)+(x%3==0)+(x%5==0)==2){
     printf("Number is divisible by 2 of 3 primes less than 7");
     }


...Try doing that with &'s and Or's...?

Name: Anonymous 2011-09-03 23:09

>>19
No it isn't. I can cite trivial C code where the whole "integers can be booleans" fails. Can you? I bet not because you're a fucking moron that has never written anything beyond simple C programs. Now shut up and go clean another toilet you annoying stupid fuck.

Name: 0n3n7 2011-09-04 0:41

>>30
something like this..?
int a=0;
a = !a;

>>following 29
Now try with +3 ??
It gets ugly fast...
Fuzzy logic is it?

Name: Lesbianism 2011-09-04 5:31

>>27,29,31
No. You are wrong. And stop bringing your fuzzy logic with you, ``Jew''.

Name: Anonymous 2011-09-04 9:39

>>32
Don't converse with him!!!!! He's one of those weird Australians.

Name: Anonymous 2011-09-04 9:49

>>33
sage

cool story, broseph

Name: Anonymous 2011-09-04 11:58

>>31
I was thinking of something like the following..

a = 2;
b = 3;
if (a) printf(" a is true\n")
if (b) printf("b is true\n");
if (a == b) printf("a == b\n"); else printf("a != b\n");

Name: Anonymous 2011-09-04 15:57

>>21
Meh, you don't need to.
Safety makes sense.

Don't change these.
Name: Email:
Entire Thread Thread List