REMEMBER PHP

# MINTE9 2REMEMBER

### Decimal

An integer can be specified in decimal (base 10).
`````` RunCode
echo 10; // Output 10
echo -1; // Output -1
echo  0; // Output 0
echo 1452; // Output 1452
```... 1 more rows˄˄˄```

### Octal

This is Unix style access permision, identified by its leading zero - 0755. We use octal when we need a readable format for bit string in group of 3.
``````
rw-r--r-- = 110100100 (binary) = 644 (octal)

READ (1) WRITE (1) EXEC (1) = binary 111 = octal 7
READ (1) WRITE (1) EXEC (0) = binary 110 = octal 6
READ (1) WRITE (0) EXEC (0) = binary 100 = octal 4
```... 1 more rows˄˄˄```
To convert decimal to octal, use modulus.
``````
97 (decimal) = 141 (octal)

97 % 8 => reminder 1
12 % 8 => reminder 4
1  % 8 => reminder 1

1*8^2 + 4*8^1 + 1*8^0 = 64 + 32 + 1 = 97
```... 2 more rows˄˄˄```

Base 16 notation, identified by its leading 0x. Hex numbers are often used to represent colours. Orange is represented as #FFA500 (255 red, 165 green, 0 blue).
`````` RunCode
echo 0x121; // 1*16^2 + 2*16^1 + 1*16^0 = 256 + 32 + 1 = 289
echo 0xFF; // 15*16^1 + 15*16^0 = 240 + 15 = 255
``````

### Binary

To conver binary to octal, convert first to decimal, then to octal.
`````` RunCode
echo 0b110100100; // 420 - decimal
echo bindec(110100100); // 420 - decimal
echo decoct(0b110100100); // 644 - octal

echo 0644; // 6*8^2 + 4*8^1 + 4*8^0 = 384 + 32 + 4 = 420
```... 1 more rows˄˄˄```
A more simple way is using groups of 3 bits. A bit has 0/1 values, a byte has 8 bits.
``````
1010111100 (binary) = 1274 (octal)

001 010 111 100 // 00 are added to complete group of 3 bits

001 010 111 100 (binary) = 1274 (octal)
``````

### Float

! Be aware that the float data type is not always capable of representing numbers. The result of this simple expression is stored internally as 7.999999
`````` RunCode
echo ((0.1 + 0.7) * 10); // output 8

echo (int) ((0.1 + 0.7) * 10); // output 7
``````
`````` CompleteTask
/**
* Compose \$m octal value using myFunc() recursively
* Use reminder and quontient values
*
* 97 (decimal) = 141 (octal)
* 97 % 8 => reminder 1
* 12 % 8 => reminder 4
* 1  % 8 => reminder 1
*
* 1*8^2 + 4*8^1 + 1*8^0 = 64 + 32 + 1 = 97
*/

function myFunc(\$no) {

...
}

echo myFunc(97) == 141; // true
``````
solution code
Questions
No. 6   Variables Definition
CARD
05
96

A B C D E F
ðŸ””
1/3