CT GunZ Server
Would you like to react to this message? Create an account in a few clicks or log in to continue.
CT GunZ Server

CT GunZ EN-Forums
 
HomeHome  PortalPortal  Latest imagesLatest images  SearchSearch  RegisterRegister  Ger Forums  GunZ Register  Server  VOTE please  Be Donator  Download CTGunZ  Log inLog in  

 

 Coding TuT 10

Go down 
3 posters
AuthorMessage
bossxd
BANNED
BANNED
bossxd


Male

Number of posts : 21
Location : usa
Points : 64
Character : Noname
GunZ Exp (nub/pro) :
Coding TuT 10 Left_bar_bleue0 / 1000 / 100Coding TuT 10 Right_bar_bleue

Registration date : 2009-04-12
Reputation : 0


Coding TuT 10 Empty
PostSubject: Coding TuT 10   Coding TuT 10 EmptyTue Apr 14, 2009 10:48 am

arithmetic

Computers as overgrown calculators.

Simple arithmetic.
Addition and subtraction work intuitively, using + and -. Multiplication is performed using * and division using /. The one principle to remember is 'precedence'. When you combine arithmetic calculations in one statement, it can lead to unexpected results.

2 + 3 * 4 = 14
If you were expecting 20, you are reading the arithmetic as you would enter it into a calculator. The compiler uses precedence rules to resolve the ambiguity in the example calculation. Multiplication and division have the higher precedence, so the compiler actually performs 3*4 before the 2 + in the example. To make sure your calculation works as expected, use parentheses:

(2 + 3) * 4 = 20
2 + (3 * 4) = 14
Modulus
Many computerised systems use numerical codes to represent real-world products. To prevent simple typing errors causing the selection of the wrong product, these codes are not sequential. Instead, the first or final digit of the code is calculated from the rest of the digits to create a checksum. Validation of this checksum is possibly the most frequent arithmetic calculation because it is used every time a barcode is scanned. An important part of the calculation is usually the modulus operator which calculates the remainder of a division. Instead of calculating a floating point number to express the fraction, the modulus operator returns the remainder.

12 % 3 = 0; // (12 / 3 = 4.00000 or 4 with no remainder)
13 % 3 = 1; // (13 / 3 = 4.33333 or 4 with a remainder of 1)
Mathematical functions
The standard library provides functions for angles, logs, exponentials, powers and square roots.

Function Description
sin(x),asin(x),sinh(x) sine, arcsine, hyperbolic sine of value x
cos(x),acos(x),cosh(x) cosine, arccosine, hyperbolic cosine of x
tan(x),atan(x),tanh(x) tangent, arctangent, hyperbolic tangent
log(x), log10(x) natural base or base-10 logarithm of x
exp(x) e to the power of x
pow(x,y) x to the power y
sqrt(x) square root of x
Remember that most of these functions will return a float value and that sqrt(-1) is not valid in simple arithmetic!

Number and text conversions
printf can convert digits into strings and C also provides functions to convert char string[] = "100"; into int digit = 100;.

char string[] = "100";
int digit = atoi(string);
atoi() converts an alphanumeric string to an integer. Other examples include:

float fraction = atof(string);
long number = atol(string);
string = itoa(100);
string = ftoa(100.00);
string = ltoa(number);
Back to top Go down
Snake
Retired Staff
Snake


Male

Number of posts : 3572
Age : 31
Location : UK
Points : 3473
Character : Coding TuT 10 Snake11copy-1
GunZ Exp (nub/pro) :
Coding TuT 10 Left_bar_bleue99 / 10099 / 100Coding TuT 10 Right_bar_bleue

Registration date : 2009-02-02
Reputation : 27


Coding TuT 10 Empty
PostSubject: Re: Coding TuT 10   Coding TuT 10 EmptyTue Apr 14, 2009 2:49 pm

Nice one.
Back to top Go down
Tittenfee
Retired Staff
Tittenfee


Warnings : 2.99
Male

Number of posts : 2522
Age : 30
Location : Austria, Vienna
Points : 2583
Character : Tittenfee, _NPC_
GunZ Exp (nub/pro) :
Coding TuT 10 Left_bar_bleue69 / 10069 / 100Coding TuT 10 Right_bar_bleue

Registration date : 2009-01-22
Reputation : 22


Coding TuT 10 Empty
PostSubject: Re: Coding TuT 10   Coding TuT 10 EmptyWed Apr 15, 2009 9:45 am

cool one*spams with snake together*
Back to top Go down
Sponsored content





Coding TuT 10 Empty
PostSubject: Re: Coding TuT 10   Coding TuT 10 Empty

Back to top Go down
 
Coding TuT 10
Back to top 
Page 1 of 1
 Similar topics
-
» Coding TuT 11
» Coding TuT 12
» Coding tut
» Coding TuT 2
» Coding TuT 3

Permissions in this forum:You cannot reply to topics in this forum
CT GunZ Server :: Basket-
Jump to: