It’s done. I have implemented support for parentheses, including nested ones. Here’s a screenshot of some test strings:
Now that it apparently works, I’m going to stop there for a while before I maybe implement support for other stuff like exponents, including square roots, or any roots, for that matter, which really are just the same as x^(e/p), where x is the expression under the root, e is the power of the expression and p is the root. Now, I still don’t even know if the thing works with decimals, because one of the functions I use to convert the input, a string value, to actual numbers for the arithmetic function to work with only returns integer values. I’ll have to change that. In fact, I’ll try without changing that first:
Yup. Doesn’t work. You know, if it turns out I have to rework the whole fucking arithmetic function just to account for a few fucking decimal points, I’m going to be very fucking angry, indeed. That would be the ultimate slap to the face for being so fucking retarded as to not include that in the first place. Why I didn’t anyway is beyond me. I should have just made the fucking thing a fucking string-to-double instead of a fucking string-to-integer. Here I am sitting and developing a fucking calculator without the fucking foresight to include decimal support. Good fucking job, asshole.
Anyway, I’ll try doing that now. By that, I mean making the string-to-integer function return a fucking double value instead. I really
couldn’t can’t imagine why it should even matter, because the arithmetic function only cares about operators… unless I programmed it to only register numbers and operators and discard everything else. If so, why didn’t I just program in an if statement checking whether or not it’s an operator that’s being tested at the moment instead of causing myself massive asspain by differentiating between every fucking character in ASCII? Whatever. It’s not like I know this yet. Hopefully, it should be enough to return a double value.
[FIVE MINUTES LATER]
Well, I’ll be fucking damned. It actually wasn’t a pain in the ass for once. A few variable changes later, including adding the dot to the list of acceptable characters in the newly
changed upgraded string-to-double function, it seems everything works as it should, this time with double support! Ha! It’s a pun, because it supports both values 10^x and 10^-x this time around.
Well, for simpler expressions it works, at least. Perhaps I should try some more complicated expressions? And why do I keep insisting on writing “equations”? These are not equations!
[TWO-ISH MINUTES LATER]
Doesn’t work. Programming is fucking shit and I’m fucking sick of it. Fuck this fucking shi-
God dammit. More debugging… Why does everything I make break? Now I gotta go fix this broken piece of shit yet again!
… Unless the calculator is broken. You see, I have been matching my results with the built-in Windows 7 calculator (calc.exe), and it gave this result for the expression from which I got -2.9 as an answer:
Notice something odd? Well, I didn’t really pay attention as I was testing a few minutes ago until I plopped this very expression into semper-fidelis Symbolab. Well, actually, Symbolab also got it wrong, because this is the correct input. Unless I pasted the wrong one in. Regardless, I found the problem: calc.exe doesn’t like me pasting in expressions having decimal points in the form of periods as opposed to the actual commas I am supposed to use because my operating system is Norwegian, unless that’s just inherently a feature to calc.exe. Whatever the reason, notice that the number which should be 4.5 is actually 45 in the input as shown in the leftmost image above. Well, of course it’s going to be wrong if the fucking program won’t accept the input properly!
I am just going to assume the piece of shit works. I have had enough of debugging for one day. Thank fucking shit for the debugging feature of Code::Blocks where I can keep track of the variables, especially strings. Now, it’d be nice if the fuckers developing Code::Blocks would somehow make tracking vector values possible, but I don’t know how that works and who is responsible for this not being possible, so I’ll cut them some slack. Well, I would if their program wasn’t fucking dogshit as far as that one incident where I lost the functionality of my project goes.