Monday, August 10, 2009

 

down in the metal

I just wanted to say that I didn't think I would ever write low-level C code again. And yet, here I am:


+(NSNumber *) getRandomDoubleMin:(double)min max:(double)max {
srandomdev();
int nRange = (int) max-min;
int nRand = random() % nRange;
double dRand = (double) nRand;
dRand = dRand+min;
int nRand2 = random() %10000;
double dRand2 = (double)nRand2;
dRand2=dRand2/10000;
dRand=dRand+dRand2;
return [NSNumber numberWithDouble:dRand];
}


(It's just a utility function to help populate a map with an assortment of randomly distributed pushpins, for test purposes. But still. Sheesh.)

Comments:

Post a Comment

Subscribe to Post Comments [Atom]





<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]