In general you should declare variables in the narrowest scope as possible - I don't always follow this rule myself, but I did in this case. A good compiler will not produce anymore overhead for declaring the num variable inside the loop. As far as using a try/catch, you may be right... I don't remember my thought process at the time, but maybe I planned to do a separate video on exceptions and the try/catch.
so every time isOperator is called the string will be allocated space and the symbols loaded? or is the compiler smart enough to see that and just load it once outside the scope of the program and just use a pointer for it ? or am i totally getting it wrong here :D
Performance does not need to be considered here as the number of calculations is small and is human driven program. Trimming programs is normally not needed until there is a real need for it. Makes code better structured by using stack I would say. So I think I would also use stack.
Brock X Because the argument could be set also that making the program even faster we could add some assembly code in it instead of C++ code. Yes it would be even faster, but it would be harder to read for programmers. And that is the whole purpose of C++: to make code better structured and more readable. Sometimes it means a bit worse performance, but we sacrifice it a bit sometimes to get better looking code. But again it depends.. if performance was really needed, then yes we would need to trim it and do it even if the code looks less structured.
Brock X Yes sure if its millions of operations per second, then must read the documentation and check which is fastest. But with this calculator its not the case... its only couple of operations per second required.
Americans dont have £ on our keyboards so we can call # pound without a name conflict. As to why we call it pound i think it has something to do with telephones
THIS IS AMAZING! THANKS PLEASE MAKE MORE VIDEOS LIKE THIS!
This is EXTREMELY helpful!
Very helpful!!! Thanks very MUCH!
What a fantastic video
Thanks , your program really helped me in writing on my Android Calculator , Thanks again man.
In general you should declare variables in the narrowest scope as possible - I don't always follow this rule myself, but I did in this case. A good compiler will not produce anymore overhead for declaring the num variable inside the loop. As far as using a try/catch, you may be right... I don't remember my thought process at the time, but maybe I planned to do a separate video on exceptions and the try/catch.
Thank you very much for a great video and your clear explanation!
Very good explanation, thank you.
outstanding. thanks.
Sooo good
when you just compiled the program
what happens if i wanna do
1.2
- (subtract)
2.9
q (quit)
???
This helped a lot, thanks!
thank you for this vid! it helps alot 😊
thanks a lot!
so every time isOperator is called the string will be allocated space and the symbols loaded? or is the compiler smart enough to see that and just load it once outside the scope of the program and just use a pointer for it ? or am i totally getting it wrong here :D
You sound like Bill Gates...
Thank you for the tutorial !!
What if you divide by zero? Goodbye processor?
Is there no other way of translating the operator char into an actual operator? I have those long else if stacks...
use a map that has a string for a key and a pointer to a function with two doubles as arguments and returns a double.
If I want to do some operations with Trigonometric operators then what should to do?
How can i transform this code in prefix polish notation not revers ?
how can i change the programm to use also e function ? example: 3e-2... ?
Why use stack instead of vector? Vector gets better performance.
Performance does not need to be considered here as the number of calculations is small and is human driven program. Trimming programs is normally not needed until there is a real need for it. Makes code better structured by using stack I would say. So I think I would also use stack.
jpkfox Ah I see.
Brock X
Because the argument could be set also that making the program even faster we could add some assembly code in it instead of C++ code. Yes it would be even faster, but it would be harder to read for programmers. And that is the whole purpose of C++: to make code better structured and more readable. Sometimes it means a bit worse performance, but we sacrifice it a bit sometimes to get better looking code. But again it depends.. if performance was really needed, then yes we would need to trim it and do it even if the code looks less structured.
jpkfox I'm glad I chose to use vectors then. I am making a program that requires millions of calculations, so performance is important.
Brock X Yes sure if its millions of operations per second, then must read the documentation and check which is fastest. But with this calculator its not the case... its only couple of operations per second required.
is it works on variables?
why do you say pound include instead of hash include. # = hash, £ = pound.
Can't be certain, but I believe it's an American thing. I knew "#" all my life as "pound" until twitter came along.
Americans dont have £ on our keyboards so we can call # pound without a name conflict. As to why we call it pound i think it has something to do with telephones
Because we aren't all British Wankers
may i get the codde
heya i wrote EVRYTHIN like in dis wideo, and 5 4 + printed out 1.25 WOOOT