Wednesday, 14 August 2013

Represent computer function logic as Math function

Represent computer function logic as Math function

Say I have a simple C function that returns a "result" for a number, based
on doing some calculations with pre-defined ranges. How can I represent
this function in a "mathematical" form with all its related symbols etc.
const int lowEndExample1 = 30;
const int highEndExample1 = 33;
const int lowEndExample2 = 60;
const int highEndExample2 = 63;
int GetResult(int num)
{
int rc = 0;
if (num >= lowEndExample1 && num <= highEndExample1)
rc += 10;
if (num >= lowEndExample2 && num <= highEndExample2)
rc += 20;
return rc;
}

No comments:

Post a Comment