Thread: maths and c++

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    9

    Red face maths and c++

    Do you need to be good at maths to become a decent programmer? I know the programming language is huge, there are many areas,, but just for the most part/in general? What areas in c++ should I avoid?

    Im wondering if im wasting my time, because im quite horrible at maths. Im reading C++ Without fear, I find myself skipping a few things because I dont get prime numbers for example. Otherwise things go smoothly, I have learned variables, if / while / else, a little about loops, functions and such.

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Quote Originally Posted by mkeisu View Post
    I dont get prime numbers
    That's easy. Just divide 19 by a number with no fractions so that you are left with a number with no fractions and you'll get it.

  3. #3
    Registered User
    Join Date
    Apr 2007
    Location
    Greece
    Posts
    52
    If you don't like 19, you can try 31, 63 etc which are Mersenne Primes.
    ...To be on topic, programming needs maths if you want to understand some underlying concepts. But if you are not really interested in these parts of programming and you can avoid them, then go on.

  4. #4
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    It depends on what level of math you're talking about.
    If you don't know how to do elementary school math, you'd have a hard time finding any job above minimum wage.
    If you were able to get through high school math, but you just don't know really advanced stuff like calculus & trigonometry, that should be fine for most programmers. The only time you'd need that level of math is if you were working on some kind of encryption or compressions algorithms, or a few other things like that.

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    No big math lessons are necessary. I doubt you'd cover things such as bases anyway, which can be quite frequently used in programming anyway. I've found mostly that only basic math skills is required for some formulas such as calculating % done or such.
    Have no fear. Prime numbers are evil =)
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    If Discrete math is a hurdle that is too high, then it will be a difficult road I'm afraid.
    Last edited by medievalelks; 05-18-2008 at 08:04 AM.

  7. #7
    Registered User
    Join Date
    May 2008
    Location
    Paris
    Posts
    248
    because im quite horrible at maths
    Trying to program your maths just learned is quite a useful way to learn both.

    Mathematics care about the definition of objects (functions, spaces, etc etc) and their coherence. With programming you can construct those objects. Constructing objects and play with them can really help to understand complex theorems.

  8. #8
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Boolean algebra is probably the most common thing you'd use:
    http://en.wikipedia.org/wiki/Boolean...ntroduction%29
    I think that site makes it look a little scarier than it actually is.

  9. #9
    Registered User
    Join Date
    May 2008
    Posts
    9
    thanks everyone

  10. #10
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    The good news is that most programming doesn't involve much math... And, the computer can do the calculations for you if you know how to set-up the expression.

    I've been programming (mostly as a hobby) for several years, and I've never needed any calculus or other "higher math". I may have used some trigonometry, and I have done lots of "simple math", number-manipulation, and bit-manipulation.

    Most beginning C++ books require very little math. You'll need to understand Boolean logic (AND, OR, NOT, XOR), which is a mathematical concept. And, you do need to know something about binary (base 2) for bitwise operations, and it also helps to know something about hexadecimal (base 16).

    The bad news is that in order to become a professional programmer (or "software engineer") you will need lots of math. If you major in Computer Science in college, you will be required to take calculus just like any other science or engineering major. (I have a friend who has a job as a professional programmer, and he majored in math!)

    The other bad news is that (good) programming requires logical/analytical/abstract thinking, and it requires accuracy & precision. So, people who are good at math can be good at programming, and people who are poor at math tend to have a hard time with programming.

    If you really enjoy programming, you may develop new attitude toward math, and there is a good possibility of becomming much better at it!

    What areas in c++ should I avoid?
    I'd hate to see you "avoid" anything.... I'd rather see you "dig into" the math as-needed. cpjust mentioned encryption and compression... A couple of other math-heavy areas that come to mind are DSP (digital signal processing) and graphics, especially animation.

    And most of the time, you can find a pre-written library for all of these areas. So, it's not always necessary to understand all of the math behind the functions you are using.
    Last edited by DougDbug; 05-19-2008 at 02:07 PM.

  11. #11
    Registered User
    Join Date
    May 2008
    Posts
    9

    Thumbs up

    Quote Originally Posted by DougDbug View Post
    The good news is that most programming doesn't involve much math... And, the computer can do the calculations for you if you know how to set-up the expression.

    I've been programming (mostly as a hobby) for several years, and I've never needed any calculus or other "higher math". I may have used some trigonometry, and I have done lots of "simple math", number-manipulation, and bit-manipulation.

    Most beginning C++ books require very little math. You'll need to understand Boolean logic (AND, OR, NOT, XOR), which is a mathematical concept. And, you do need to know something about binary (base 2) for bitwise operations, and it also helps to know something about hexadecimal (base 16).

    The bad news is that in order to become a professional programmer (or "software engineer") you will need lots of math. If you major in Computer Science in college, you will be required to take calculus just like any other science or engineering major. (I have a friend who has a job as a professional programmer, and he majored in math!)

    The other bad news is that (good) programming requires logical/analytical/abstract thinking, and it requires accuracy & precision. So, people who are good at math can be good at programming, and people who are poor at math tend to have a hard time with programming.

    If you really enjoy programming, you may develop new attitude toward math, and there is a good possibility of becomming much better at it!

    I'd hate to see you "avoid" anything.... I'd rather see you "dig into" the math as-needed. cpjust mentioned encryption and compression... A couple of other math-heavy areas that come to mind are DSP (digital signal processing) and graphics, especially animation.

    And most of the time, you can find a pre-written library for all of these areas. So, it's not always necessary to understand all of the math behind the functions you are using.
    very helpful reply, thanks I only want to learn it as a "hobby". I read networking in high school, but I suspect I could choose to study programming should I decide to complement my grades and study further.

    Anyway, right now im only at the basics. I only wanted to know what to expect

  12. #12
    Registered User
    Join Date
    May 2008
    Location
    Paris
    Posts
    248
    For me, maths is the best way to learn programming, especially object-oriented or generic, and programming is the best way to learn maths. Think about how class inheritance and templatisation are represented mathematically, and you will learn these concepts in both domains.

    When you program your mathematical classes and functions correctly, the compilation can really be equivalent to a conceptual verification of your maths. This will take some time though.

    I am programming c++ for over three years now, but only since a while I have the feeling to be able to construct something. And still asking a lot of questions and making a lot of mistakes. Very probably my libraries are not the best and not fully industrial proof with scientific performance.

    But it is really fun and a challenge, so invest some years in it!

Popular pages Recent additions subscribe to a feed