Math And Stuff Dont Freak

Math and Stuff (Don't Freak)

Math is a core part of any programming language but let me say a quick word on that. There is a saying that to be good in computer programming, you need to be good at math. However, I don't think (actually I pretty much know for a fact) that it isn't strictly true. What I think is meant by that is that it helps to think logically and mathematicians tend to think very formally and logically. That isn't meant to say that other people don't, it just happened that alot of the original computer people were hard core math types and the stereotype stuck. But that's all it is...a stereotype.

Math basically has three parts

  1. Numbers - The digits.
  2. Operators - The symbols that tell what math to perform.
  3. Order of Operations - In what order is everything completed.

Oh relax, we're not doing brain surgery here nor are we doing a calculus final. Take a breath!

As we've already seen, we wrap a math problem in #s like #5+3# which evaluates to 8. Here are the other mathematical operators:

  • is for addition #5+7#=<cfoutput>#5+7#</cfoutput>
  • is for subtraction #5-2#=<cfoutput>#5-2#</cfoutput>

/ is for division #5/2#=<cfoutput>#5/2#</cfoutput>

  • is for multiplication #53#=<cfoutput>#53#</cfoutput>

Mod is short for modulus which is the remainder after division. #9 mod 2# = <cfoutput>#9 mod 2#</cfoutput>

^ is used for exponents. #9^2#=<cfoutput>#9^2#</cfoutput>

<strong>Exercise</strong>: I don't think we need one for this page, do you? Keep it it mind as a reference