9/12/2013

Bash Shell Math

While the bash shell can only do integer arithmetic, it can do it in several ways:
Double Parenthesis, Dollar Square Brackets. the let statement, and command substitution of expr which was used to arithmetic in the original Bourne Shell, sh.

Double Parenthesis

x=$(( 5 * 3 )) ; echo $x
15

y=$(( $x / 4)) ; echo $y
y=$(( x / 4)) ; echo $y # dollar is optionaly
# Floor division rounds down always

Increments/Decrements
y=0
((y++)) ; echo $y
1
((y--)) ; echo $y
0
((++y)) ; echo $y
1
((--y)) ; echo $y
0
((y+=2)) ; echo $y
2
((y-=2)); echo $y
0

Different Base Numbers
x=$((2#0101)) ; 
echo $x
5
x=$((16#ff)) ; echo $x
255
Also:
echo $((0xff)) # hexadecimal
255
echo $((0Xff)) # hexadecimal
255
echo $((077)) # octal
63


Dollar Square Brackets

x = 0
x = $[ $x + 1 ]
echo $x
1

let Statement

The let statement is special in that expressions can dereference the value of a variable without using the dollar symbol. For example,
ec
let x=3
let y=4 + x
echo $y
7

expr Command Substitution

x=`expr 3 + 4`
echo $x
7



Ad Word Soup: Decoding the acronyms CPA, CPC, CPI, CPM, CTR

Ad Word Soup: Decoding the acronyms

Others may go into greater detail, but here's what the acronyms mean that are used in on-line advertising.

CPA - Cost Per Action

CPA is cost per action or payment for when user acts upon an ad

CPC - Cost Per Click

CPC is cost per click or payment for when a click on an ad occurs

CPI/CPM - Cost Per Impression(s)

CPI is cost per impression
CPM is cost per 1000 impressions

CTR - Click Through Rate

CTR is the number of clicks divided by the number of impressions times 100. 
It is normally expressed as a percentage. For example,
If 5 people click out of 100 impressions, then the CTR would be 5%. 

Click Fraud

Fraud is a problem, as well as people gaming the system 

What Advertising Model To Use


About Me - WrightRocket

My photo

I've worked with computers for over 30 years, programming, administering, using and building them from scratch.

I'm an instructor for technical computer courses, an editor and developer of training manuals, and an Android developer.