Sunday 2 October 2011

Primitive data types

1. What is primitive data type ? A basic primitive data type is either of the following:
a.Numbers
i. Whole numbers
-– bytes = 8 bits –1 Bytes
--- Short = 16 bits – 2 Bytes
--- Int / Integer = 32 bits – 4 Bytes
--- Long integer = 64 bits ---- 8 Bytes

Operation involve in whole numbers : +,­,*,/ .If there more than one operator in an arithmetic operation,look at its priority . Operation priority first (* / ),followed by            (+ -).Example :
4-2*5 = -6
4*5/2 = 10

For remainder,we use modulus aka % example,15%6 = 15 MOD 6 = 3 .More example :
8%4 = 0
8%3=2
21%5=1
15%6=3

Operator – Prefix
             -- Postfix
                
 ii.Real numbers ( with decimal)
---Float – 4 Byte – Single precision
---Double – 8 Byte – Double precision

b. Alphaneumeric – Combination of numbers and alphabet ,example SKJ 1013

c. False / True (Boolean).It uses 3 logical operator :
AND - &&
OR = II
NOT = !

And uses relational logic operator :
>
>=
< 
<=
== Equivalent,Example ( n=0,ie n is assigned to 0),but (n==0 ie is n equal to 0? )
!= Not equal

0 comments:

Post a Comment