Hey guys,
So... my puny little humain brain has reached its limits here. My pitiful little mere-mortal perspective has no logical explanation here... so, given this code:
Code:
// Compiling on Linux Mint x64 with gcc.


// Where "tokens" is was i.e. "-4 + -4"
char whatThe[10000];
sprintf(whatThe, "%s", tokens + start - 1);
printf("My string is \"%s\"\n", whatThe);
printf("f1 = %g\n", atof(whatThe));
printf("Okay, so then why the PUCK does this work? %g\n", atof("-123.45"));
I get this output:
Code:
My string is "-4"
f1 = 0
Okay, so then why the PUCK does this work? -123.45
So.............?????????????????????.............. ...............................


My code works fine with positive numbers, and it's giving me correct strings when using negative numbers, but there's something in atof that feels the need to drive me to drink tonight. One website says this: "double value corresponding to the contents of str on success. If the converted value falls out of range of the return type, the return value is undefined. If no conversion can be performed, 0.0 is returned." Zero is what I'm getting... soooooooo......... (scratches head)...........??????????????????????? I suppose a logical question might be, how do I discover the reason the compiler thinks "no conversion can be performed"? I'm guessing I must've made some ultra-subtle infuriating micromistake that is causing this nonsense. I'm at the point of DIY'ing my own atof() replacement that is human-reasoning-compliant.


Code:
while(true) {
    hair--;
    frustration++;
    exhaustion++;
    if (asleep) printf("Finally, a break from depuzzling!"); // :D
}