|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
Probably a basic question, but....
Ok, I've never known what this code actually does:
PHP Code:
My books don't have any explination (sp?) on that. Last edited by Raven_Writer : 16-01-2004 at 13:54. |
|
#2
|
|||
|
|||
|
Re: Probably a basic question, but....
Quote:
conditional statement ? statement executed if true : statement executed if false; I'm assuming that extra 0 stuck in there after hi is a typo? |
|
#3
|
||||
|
||||
|
Re: Probably a basic question, but....
are you sure it's not
Code:
int hi = 0; return hi ? 1 : 0; Code:
int hi = 0; if(hi) return 1; else return 0; Code:
a ? b : c; so you could use Code:
var1 += (x>2 ? 4 : 1); it's more than just a compact way of doing if statements, as i've illustrated - you can't embed a if statement in an expression, whereas you can embed the ternary operator. |
|
#4
|
|||||
|
|||||
|
Re: Probably a basic question, but....
Quote:
Quote:
).It might make if-case statements more easier |
|
#5
|
|||||
|
|||||
|
Re: Probably a basic question, but....
Here's another question....
I was searching through the default code for the tracking. I opened up "ifi_default.h", and saw that in the struct's, it'd have like: "unsigned int pie:1;" My question now is, does the colon take the place of the equal sign? |
|
#6
|
|||||
|
|||||
|
Re: Probably a basic question, but....
Quote:
|
|
#7
|
|||||
|
|||||
|
Re: Probably a basic question, but....
Quote:
I just that it was another way to assign a variable. |
|
#8
|
||||
|
||||
|
Re: Probably a basic question, but....
it basically allows you to save space - you could use each of the 16 bits of an int to store a different 1/0 value, approximating a set of 16 booleans
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| A question about control system options | computhief263 | Control System | 7 | 04-02-2004 14:46 |
| Very Basic Programming Question | kewlkid382 | Chit-Chat | 5 | 18-01-2003 11:11 |
| Rookie Programmer has question about the default code | DanL | Programming | 3 | 26-01-2002 19:59 |
| Question about Basic Stamp | miketwalker | Programming | 3 | 14-01-2002 13:10 |
| Have a question about the Basic Stamp Chip Boards | wes16zeus | Programming | 3 | 06-12-2001 08:25 |