Yo no hablo C code. I was trained on Fortran, believe it or not, and yes in the 21st century. Et je ne parle pas la OOP, either, but I will give it the old college try.
Let's see, I must assume the datatype, structure, object or whatchamacallit "DateTime" comes from an included header file way before and as such need not be defined here. The inline if syntax looks right after a quick search, parentheses don't appear to be necessary for the order of operations to work.... Is this C#? DateTime appears to be a C# language object, or maybe .NET? Ich verstehe diesen Sprache noch schlimmer!
Well, assuming all the function overloading works like its supposed to, and the methods (or thingamajiggers) after the dots do what they imply they do, and all the variables you're using (specifically gcData) are within the function's scope, I can only see one possible problem comparing this code to another sample using C# DateTime.
Code: Select all
// DateTime today = DateTime.Today; // IS WRONG
DateTime today = System.DateTime.Today; // IS RIGHT ???
Well, maybe one more thing. This could be a problem in some languages, and I don't know whether/how C-family languages handle automatic datatype conversions... poorly I think.
Code: Select all
return pointsPerYear * (yearsOld + (double)days / (double)daysInYear);
Your return statement here is multiplying pointPerYear (unknown to us whether declared as integer or real) with a sum that is an integer plus a real divided by a real. You're adding a double precision quotient to the integer yearsOld. Is that the problem? If so, every cache is going to come out with a score of 0, 100, 200, 300, etc. I hope I'm right!
Otherwise, I
think your algorithm is sound, and now I know why you weren't concerned about handling anniversary dates and leap years... you've got an object/class thingamadoodle that does it for you! I thought you'd be doing this in a query with SQL, but looks like you're crunching numbers this way and then pushing it out to your database.
This is why you're doing this, not me. But if you need some MATLAB code debugged, I'm your man! Have an ODE to integrate, just ask. Linearize equations of motion in vector notation? You should see my thesis! But C-code... let me get back to you on that.
I should really not check this board late at night... because at oh-dark-thirty it's off to work... where, ironically, I will be writing VisualBasic modules (another OOP language I don't understand) for an MS Access database....
