Primitive Data Type
Lab: Types of Data
Video Runtime: 08:58
The primitive data type is the basic building block of data. They hold one single value. They represent a string, number, or boolean.
Your key takeaways are:
- The basic building blocks of data are the primitives
- Primitives
- hold a single value
- representation for string, number, and boolean
- Each language has these building blocks
Study Notes
All data types are built off of the primitive types, so we’ll start with these.
Different Data Representations
What patterns do you see in the following table? Why are patterns important?
Patterns tell you a story. Patterns give you clues. Start watching for patterns.
How can patterns help you?
- problem-solving
- writing code
- building solutions for your customers
Data Types | Represents | Examples |
---|---|---|
boolean | literal truth-value state | true, false |
char | a single character | ‘A’, ‘z’, ‘&’, ‘!’, ‘_’, ‘1’ |
string | a grouping of characters | “Hello World”, “123” |
byte | signed 8-bit two’s complement integer | 84, -17 |
short | signed 16-bit two’s complement integer | 872, -304 |
integer | signed 32-bit two’s complement integer | -69,723 |
long | signed 64-bit two’s complement integer | 8,030,167,904,852 |
float | signed 32-bit floating-point value | -1826.001 |
double | signed 64-bit floating-point value | 5.17 x10300 |
Patterns for the Data Types
- Numbers, strings, and booleans – these are your primitives
- Hold a single piece of information – one piece of data
- Memory size is dependent upon the data type
- Knowing the difference between data types will help you craft the right solution. For example, if the system you’re building only needs a float, but you use a double, you’re allocating more memory than needed.
Terminology
- Primitive Data Type
- Primitives
Simple Primitive Data Types
Notice the similarities between the different languages?
Language | Boolean | Char | String | byte, int, integer, short |
long, float, double, real |
---|---|---|---|---|---|
PHP | ✓ | ✓ | ✓ | ✓ | |
JavaScript | ✓ | ✓ | ✓ | ||
Ruby | ✓ | ✓ | ✓ | ✓ | |
Python | ✓ | ✓ | ✓ | ✓ | |
C | ✓ | ✓ | ✓ | ✓ | ✓ |
C# | ✓ | ✓ | ✓ | ✓ | ✓ |
Visual Basic | ✓ | ✓ | ✓ | ✓ | ✓ |
You will grow in this profession when you incrementally and systematically stretch yourself....bit-by-bit.
Episodes
Total Lab Runtime: 00:48:33
- 1 Lab Introductionfree 05:36
- 2 Primitive Data Typefree 08:58
- 3 Composite Data Typefree 19:19
- 4 Special Data Typefree 03:30
- 5 Abstract Data Typefree 11:10