# Primitive

## What is a Primitive? :bricks:&#x20;

A **Primitive** is a basic building block of data, the smallest lego brick, the simplest type of data.&#x20;

![Legos](https://3642656209-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MLGBprg9M6rsaEbC96_%2F-ML_GMN18Y-XLo_TLTcF%2F-ML_Hv0jnVk0OLhzkgrx%2Fxavi-cabrera-kn-UmDZQDjM-unsplash.jpg?alt=media\&token=e3e317cf-d8b0-4b32-b6c7-c545e04e6b0e)

## Characters & Strings :speech\_balloon:&#x20;

A **Character** is a single letter and can also be a single symbol, or a single number.

* *'a'      '1'      '?'*

A **String** is a series of characters connected together.

* "Hello World!"      "jkh1?/5h51"      "aaaaaaaaa"

## Number :heavy\_plus\_sign: :heavy\_minus\_sign:&#x20;

A **Number** is a unit apart of a mathematical system and subject to rules of addition, multiplication, etc.

**Types of Numbers**: integer, float, fixed, double, real, double precision, int, short, long, byte, etc... are commonly used data types.&#x20;

* Int = Whole Number = 42 :1234:&#x20;
* Float = Real Number = 3.14 :pie:&#x20;
* Long = Big Number = 2,147,483,647 :whale2:&#x20;

**Why are there so many types?:** Storing numbers with the appropriate amount memory saves the computer from using extra resources.

* Fraction = 1/3 = .3333333 :infinity:&#x20;

:desktop:The fraction 1/3 would crash every computer ever built if stored as an infinite number because computers have limited space:desktop:

## Numbers are Not Equal to Strings or Characters :man\_judge:&#x20;

A computer treats different types of data differently. The number 1 is not the same as the character 1.&#x20;

* :no\_entry\_sign:Int "1" Not Equal  Chr "1" :no\_entry\_sign:&#x20;
* :no\_entry\_sign:Chr "1" Not Equal Int "1" :no\_entry\_sign:&#x20;
* :no\_entry\_sign:Float "3.14" Not Equal String "3.14" :no\_entry\_sign:
* :no\_entry\_sign:String "3.14" Not Equal Float "3.14" :no\_entry\_sign: &#x20;

## Boolean & Binary :full\_moon\_with\_face: :new\_moon\_with\_face:&#x20;

A **Boolean** has one of two possible values: True or False.

* :arrow\_forward: music player (play, pause):pause\_button:
* :bulb:light switch (on, off):bulb:
* :potable\_water:water faucet (open, closed):potable\_water:&#x20;

**Binary** is a number built from two possible values: 1 or 0.

* 1
* 0
* 1001001
* 1111

:desktop: A computer converts all information into 1's and 0's stores/manipulates that data and spits back what you see. :desktop:&#x20;

## Reference (Pointer):point\_right::house:&#x20;

A **Reference** is where a piece of data is in memory.

```
Address =   1   2   3
          +---+---+---+
Data =    | a | b | c |
          +---+---+---+
```

1. I want the data at address 2
2. I use the reference number 2
3. I get the data I want 'b'

A **Reference** can be thought of as a physical address, a bank account number, a bitcoin wallet, or venmo/cashapp/zelle address.  &#x20;

* Citing original sources in a research paper :scroll:&#x20;
* Paying a friend back for pizza using venmo :pizza:&#x20;

:money\_with\_wings: peer-to-peer mobile payment apps are good examples because you dont know whats in someone elses account but you do know how to request money or send money to that account:money\_with\_wings:&#x20;

## Story Time: Ancient Atomic Theory:atom:

The inventor of atomic theory, Democritus, a Greek philosopher:thinking:who lived in 500 B.C. He imagined continuously cutting an item in half. if he cut a rock in two, he knew the halves would have the same properties as the whole. If he continued cutting forever, he hypothesized a limit where his rock was uncuttable. The piece was as small as it could possible be (indivisible). These uncuttable pieces he called "atomos", the Greek word for indivisible.

> "Nothing exists except atoms and empty space; everything else is opinion."  Democritus
