mikeage.net Logo
mikeage.net/2006/10/page/3/

mikeage.net @ י״ד תשרי תשע״ט

Archive for ‍‍ תשרי / מרחשון תשס״ז - October, 2006

Dividing Integers (& Casting Precedance)

‍‍כ״ה תשרי תשס״ז - Tuesday, October 17th, 2006

Quiz:
What does the following code print:

int i,j;
float k;
i = 5;
j = 2;
k = i/j;
printf("%f\n",k);

(more…)

Conditional Assignments

‍‍כ״ד תשרי תשס״ז - Sunday, October 15th, 2006

Sometimes, you'll have a scenario with two variables, and you need to use one of them based on a simple test. Rather than a long and awkward if / else statement, C allows the use of the ? : form. It is perfectly acceptable to write:

int i,j,k,l;
...
i = (j > 5? k : l)

which will set i to k if j is greater than 5, and l otherwise.
Another common use is [sf]?printf statements:

printf("The test %s\n",(status == OK) ? "passed" : "failed");

However, one can't use it to handle selective assignments. The following code is illegal:

int i,j,k;
...
((i>5) ? j : k) = 5;

This cannot be used to choose whether j or k is set to 5.
There is, however a way this can be done. Using pointer, we can select which one to deference:

*((i>5) ? &j : &k) = 5;

This will work.

Preprocessor #s, ##s, and other weird stuff

‍‍כ״א תשרי תשס״ז - Friday, October 13th, 2006

In the post on strings for enums , I used two types of pound symbols in the preprocessor macros: # and ##. Here's some more detail:
(more…)

Pnei Kedem Kite Festival

‍‍י״ט תשרי תשס״ז - Wednesday, October 11th, 2006

Yesterday, we went to the Kite Festival in Pnei Kedem. Overlooking (in the distance) the Dead Sea, Pnei Kedem is a small (about 20 families, IIRC) yishuv adjacent to Metzad, in Gush Etzion (our "friends" at Piece Now have a beautiful picture of Pnei Kedem... who said they don't do any good?). Every year (for the past few years, at least), they have a Kite Festival on Chol Hamoed Sukkos. On the summit of a large hill (mountain?) in the Judean Hills, they have the perfect climate for kite flying
(more…)

Site Moved (Again)

‍‍י״ט תשרי תשס״ז - Wednesday, October 11th, 2006

We've moved servers again! The DNS propogation is not yet complete, so if you get weird errors, try accessing http://64.21.48.171/ instead of http://mikeage.net/.

I think, however, that I have the proper .htaccess file to handle all of those automatically, though.

I'm still with site5.com, and I'm going to be posting a review of their service and the upgrade process soon.

Quick Map
Content +
Personal +
Archives +
Site Stuff +
RBS Weather +
Search +
Recent Images

Valid XHTML 1.1!
Printer Friendly Page
 

Last Modified: September 04, 2006 @ 02:11 CST

Memory(TRUE): 2097152/2097152
Memory(FALSE): 3035944/3045928