Lost in mathematics
Okay I have a possible really stupid question to ask and it really confused me by the way I think I was taught in school. I am refering to the < and > signs.
5<10. The way I think I was taught that it would read 5 is greater than 10 because 5 would have the big mouth eating the 10. But the way I seem to be wrong that it means 5 is less then 10. 5>10. I normally would read this as 5 is less then 10 because the mouth is eating the 5 which I would consider true. What I read would be that is false and it really reads 5 is greater then 10. I just realized all my expression I am righting are comming out backwards. So has anybody ever known that in school the way I was taught or so I thought? and just to be clear 5<10 would be 5 is less then 10 which is true and 5>10 would be 5 is greater then 10 which is false. correct? I just don't want to right a million expressions and have to rewrite it all. Just a note to all you younger generations or just people still in school. You might want to not sleep in class ;). Just to add. I wrote this to test it and it comes out like 45<10 45 is less then 10 true. Code:
#include <iostream> |
Hi jmc!
The way I was taught is that the symbol "<" means "is less than", and to interpret correctly any use of it, you just have to substitute the expression for the symbol. So "X < Y" should be read as "X is less than Y". The same goes for equivalent symbols (>, >=, <=). Your code correctly outputs "Iam am younger." because myAge < yourAge, that is, 45 < 50, that is, 45 "is less than" 50. I have heard about the "eating" interpretation, I believe you can use this way of interpreting the symbols, as long as you always consider that the "mouth" of the symbol is "greedy" and tries to eat the bigger number. If this is true, the sentence is true. I believe that more important than to use a "current generation" interpretation, you should tweak yours so that is both correct and easily remembered. Cheers! Renato. |
Yea I may have been taught like that. It has just been years since I've been in school but I got it down now. I decided to rewrite my script to be a little less boring though
Code:
// Age Test script By the way does anybody know how easy it would be to rewrite a c program into c++? I assume its like a total overhaul. |
Quote:
|
@Sergei Steshenko
I disagree. Crodile and birds according the evolution theory have the same parents. Modern C and C++ also have the same parent. But they are completely different despite some formal similarities. Learning C++ as a some kind of extension of C is a waste of time. In my opinion forget everything you learned about C if you want to learn C++. |
Think of it this way -- the wider side of the symbol points to the bigger number, and the thin, pointy side points to the smaller number.
|
Quote:
The statement I made is essentially this: http://www.parashift.com/c++-faq-lit...c-and-cpp.html : Quote:
|
Quote:
Working as a consultant i very often hear employer executives complain about that so many programmers seem to live in the clouds with their OO coding style, not knowing much of how their code actually executes in the system, and therefore bringing issues into the system which may sometimes be extremely difficult to remedy. |
All times are GMT -5. The time now is 06:54 PM. |