Category: KTSI

Galton Board in ObjectiveC

Target was to build an application to simulation a “Galton Board“. Galtonsches_Brett.h 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 #import   @interface Galtonsches_Brett : NSObject { @private   }   – (void)Calculate:(double)numBalls field0:(NSProgressIndicator**)field0 field1:(NSProgressIndicator**)field1 field2:(NSProgressIndicator**)field2 field3:(NSProgressIndicator**)field3 field4:(NSProgressIndicator**)field4 field5:(NSProgressIndicator**)field5;   – (int)RandomField; @end Galtonsches_Brett.m 1 2 3 [...]



dec2bin function

This Function converts a decimal number into a 8bit long binary number.   std::string dec2bin(int dec) { int size = 8; bool bin[size]; int counter = size-1;   if (dec > 255) { return "Maximal 255"; }   // init the array for(int i = size; i >= 0; i–) { bin[i] = false; } [...]



sqrt() Function

This is the way sqrt works… Why do i have to code this by my own? const float EPSILON = 1e-6;   float working = val; float diff = 0; float keep = 0; float result = 0; int counter = 0;   do { result = (keep + working) / 2; //std::cout << "("<<keep<<"+"<<working<<") [...]