 💽

# Information Management Concepts

Tags Computer scienceComputingDatabaseInformation Management @December 14, 2022 10:21 AM @May 20, 2023 7:02 PM

# ASCII

## Ecosystem

Standards, jobs, industry, roles, …

# Chapter Name

## Exercises

1. Logic. Mathematics. Code. Automatic Verification such as Lean Proven or Frama-C.
1. Languages in Anki.

# 0.13 Number systems

### 0.130 Positional number systems

Assume $(0)_b=0$﻿ and $(1)_b=1$﻿

Convert from $b$﻿-base to decimal. If $b\geq 2,$﻿ then

Convert from decimal to $b$﻿-base.

def a(number, k):
return math.trunc(number / math.pow(10, k)) % 10

def length(number):
return math.trunc(math.log10(number)) + 1

def from_base_to_decimal(number, b):
acc = 0
for k in range(length(number)):
acc +=def from_decimal_to_base(number, base):
return acc
def from_decimal_to_base(number, base):
base_number = ""
q = number
while q > 0:
qk = trunc(q/base)
ak = q - base*qk
base_number = str(ak)+base_number
q = qk
return base_number
function from_base_to_decimal(number, base) {
return String(number).
split('').
map((n)=> parseInt(n, base)).
reduce((acc, current, index, array) => {
console.log(${current}+${base}*${acc}=${current+base*acc});
return current+base*acc;
});
}
function from_decimal_to_base(number, base) {
if (base <= 1) {
return;
}
base_number = ""
q = number
while (q>0)
{
qk = Math.trunc(q/base)
ak = q - base*qk
console.log(${base * qk + ak}=${base}*${qk}+${ak});
base_number = ak.toString(base).toUpperCase()+base_number
q = qk
}
return base_number
}
function from_any_base_to_any_base(number, start_base, end_base) {
console.log(from base ${start_base} to decimal); const start_number = from_base_to_decimal(number, start_base); console.log(from decimal to base${end_base});
return from_decimal_to_base(start_number, end_base);
}

Fast algorithm.

http://www.opentextbookstore.com/mathinsociety/2.4/HistoricalCounting.pdf

https://www.gcu.ac.uk/media/gcalwebv2/gcuoutreach/NUMBERS & NUMBER SYSTEMS.pdf

https://www.cl.cam.ac.uk/teaching/1415/CompFund/NumberSystemsAnnotated.pdf

https://ocw.mit.edu/courses/aeronautics-and-astronautics/16-01-unified-engineering-i-ii-iii-iv-fall-2005-spring-2006/comps-programming/mud5.pdf

https://en.wikipedia.org/wiki/Numeral_system

https://ocw.mit.edu/courses/aeronautics-and-astronautics/16-01-unified-engineering-i-ii-iii-iv-fall-2005-spring-2006/comps-programming/number_systems.pdf

https://ocw.mit.edu/resources/res-18-008-calculus-revisited-complex-variables-differential-equations-and-linear-algebra-fall-2011/study-materials/MITRES_18_008_supp_notes01.pdf

https://www.cs.princeton.edu/courses/archive/spr15/cos217/lectures/03_NumberSystems.pdf

http://www.unitconversion.org/unit_converter/numbers-ex.html

COMS W3827 Fundamentals of Computer Systems

### 0.1311 Binary and boolean function

Binary vs boolean and bits

Ecosystem

## 0.14 Data Storage

### 0.141 Storing Numbers

Method of complements

Nine's complement

Ten's complement

One's complement

One's complement is an operation to invert bits.

Worked examples.

$m=-56,C(56)=2^8-56-1=199$﻿

Two's complement

There is only one zero in two’s complement notation.

One's complement + 1. Because $(0)_{one's complement}=(1)_2$﻿, but $(0)_{two'scomplement}=(0)_2$﻿

Worked examples.

$m=-56,C_{8 bits}(56)=2^8-56=200$﻿

Trick.

https://www.csestack.org/how-to-find-2s-complement/

Example. $11100110$﻿ two's complement format to integer.

### How to encode negative numbers in binary number systems?

• Gray code

• Base −2
• 8–4–2–1 code is also called BCD (Binary coded Decimal)
• Sign and magnitude
• Offset binary, also called excess-K or biased representation

Excess-8 (biased)

Zig-zag encoding

Excess-3, 3-excess or 10-excess-3 binary code (often abbreviated as XS-3, 3XS or X3), shifted binary or Stibitz code. https://en.wikipedia.org/wiki/Excess-3

• Complements
• Ones' complement
• Two's complement

Two's complement is the easiest to implement in hardware, which may be the ultimate reason for its widespread popularity. Choo, Hunsoo; Muhammad, K.; Roy, K. (February 2003). "Two's complement computation sharing multiplier and its applications to high performance DFE". IEEE Transactions on Signal Processing. 51 (2): 458–469. doi:10.1109/TSP.2002.806984.

#### Summary

Contents of memoryUnsignedSign-and-magnitudeTwo's complementOne's complement
000000+00
000111+11
001022+22
001133+33
010044+44
010155+55
011066+66
011177+77
10008-0-8-7
10019-1-7-6
101010-2-6-5
101111-3-5-4
110012-4-4-3
110113-5-3-2
111014-6-2-1
111115-7-1-0
NotesThe leftmost bit defines the sign. If is 0, the integer is positive else negative.The leftmost bit defines the sign. If is 0, the integer is positive else negative. The leftmost bit defines the sign. If is 0, the integer is positive else negative. This has two 0.

How to encode real numbers in binary number systems?

• Floating-point

IEEE 754 format

three parts: a sign, a shifter, and a fixed-point number.

### 0.142 Storing Text

A character is an element of grammar (English, Spanish, ...) + accepted human-computer interface by convention (backspace, delete, escape, @, ...), i.e. a code. $code=\{character | character \in grammar \text{ or } character \in \text{ human-computer interface} \}.$﻿

For example, English grammar is $\{A,B,C,...,Z\}\cup \{a,b,c,...,z\} \cup \{.,;,-,+,!,...,*\} \cup \{0,1,2,3,...,9\}$﻿ and human-computer interface in ASCCI is$\{NUL,SOH,Space,...CAN\}$﻿.

We can represent each character with a bit pattern of n bits (bit pattern length=n). If we have a $code=\{A\}$﻿, his cardinality $|code|=1$﻿. Then computer understands $\text{computer code}=\text{bit patterns =}\{0\}$﻿ and $\text{bit pattern length}=1$﻿

$code=\{A,B\},|code|=2,\text{bit pattern}=\{0,1\},\text{bit pattern length}=1$﻿ .

$code=\{A,B,C,D\},|code|=4,computer=\{00,01,10,11\},\text{bit pattern length}=2$﻿.

$|code|=8,\text{bit pattern length}=3,lg(8)=3$﻿.

Therefore, $\text{bitPatternLength}=lg(|code|)$﻿.

### 0.1421 ASCII Code and UNICODE

IEEE milestones.

ASCII.

UNICODE. Emojis.

printf "\r12345\n\r6\n"; printf "\r5\n"
printf "\r12345"; printf "\r5\n"

https://stackoverflow.com/questions/3091524/what-are-carriage-return-linefeed-and-form-feed

Hex Code.

How works internally?

https://www.w3schools.com/tags/ref_urlencode.ASP

https://onlineunicodetools.com/convert-unicode-to-hex

https://en.wikipedia.org/wiki/List_of_Unicode_characters

Mackenzie, Charles E. (1980). Coded Character Sets, History and Development (PDF). The Systems Programming Series (1 ed.). Addison-Wesley Publishing Company, Inc. pp. 6, 66, 211, 215, 217, 220, 223, 228, 236–238, 243–245, 247–253, 423, 425–428, 435–439. ISBN 978-0-201-14460-4. LCCN 77-90165. Archived (PDF) from the original on May 26, 2016. Retrieved August 25, 2019.

https://stackoverflow.com/questions/12747722/what-is-the-difference-between-a-line-feed-and-a-carriage-return

https://pjb.com.au/comp/diacritics.html

ASA standard X3.4-1963

https://stackoverflow.com/questions/1761051/difference-between-n-and-r

## 0.15 Operations on Data

### 0.152 Arithmetic Operations

Sum of naturals.

Rules. 0+0=0, 0+1=1, 1+0=1 and 1+1=10

Subtraction of naturals (No complements).

Rules. 0-0=0, 1-0=1, 1-1=0, 0-1=10-1=1

https://www.calculator.net/binary-calculator.html

Subtraction of naturals (Two's complement)

$91-46=91+(-46)=45$﻿

https://www.exploringbinary.com/twos-complement-converter/

## Nine's complement

Pascaline.

### 0.153 Bitwise operations in C

Bitwise Operators in C and C++

x & 1 is equivalent to x % 2 (no sign).

if x&1 is true, then x is an odd number.

First of all, an example:

5(00000101)& 1(00000001)
00000101 &
00000001
00000001 (1 True)

Informal Proof. For non-complement binary number. Where $n$﻿ is position left to right.

std::list<int> v = { 1, 2, 3, 4, 5, 6 };
auto it = v.begin();
while (it != v.end())
{
// remove odd numbers.
if (*it & 1)
{
// erase() invalidates the iterator, use returned iterator
it = v.erase(it);
}
// Notice that the iterator is incremented only on the else part (why?)
else {
++it;
}
}

x >> 1 is equivalent to x / 2

https://www.cprogramming.com/tutorial/bitwise_operators.html

IEEE 754

# File classification

In Unix, everything is a file, so what is a directory? a file, what is a process? a file, what is a driver? a file. If you don’t separate how looks and how does it, you have blobs.

Blobs and plain text.

## Blobs and byte arrays

https://security.stackexchange.com/questions/220560/rsa-key-string-vs-hex-vs-base64-vs-byte-array-represantational-form

# Images

How can you see an image? and process it? OpenCV

## PACS

PACS (picture archiving and communication system)

DICOM

png, jpg, webp

SVG and canvas

## High-performance images and animations

WebGL, OpenGL, directx, vulkan

Computer graphics

## By field

Myers Automatic Booth

### (XML, JSON and YAML, Information Technology)

https://www.npmjs.com/package/serialize-javascript

https://docs.python.org/3/library/pickle.html

## (PDF, Standard)

### DICOM Standard

https://pydicom.github.io/

DICOM networking protocol

## File as Programming

CSS, JS, HTML, WASM

# Video

The filmmaker’s handbook

# Hex editing

We tell you that files are binary, right? But, how we can you show that if you don’t feel it? And yes, you could write your programs in hex — ”since C and assembly are too high-level” you’re thinking and yes you could do reverse engineering to software.

In Unix, you have different options to edit and show files as hex. Some choices are xxd, hexdump , and so on . We’re going to use xxd and vim.

Write a plain text in Unix with “Hello World” and vim. Change to mode xxd.

But, how can show a “Hello World” in binary? xxd -b

## References

 hexdump(1) - Linux manual page. (2022, December 19). Retrieved from https://man7.org/linux/man-pages/man1/hexdump.1.html

 Top Hex Editors for Linux. (2021, May 17). Retrieved from https://www.tecmint.com/best-hex-editors-for-linux

# Extended ASCII

https://www.gnu.org/software/emacs/manual/html_node/emacs/User-Input.html

# Automation and insights

## Exercises

1. Logic. Mathematics. Code. Automatic Verification such as Lean Proven or Frama-C.
1. Languages in Anki.

## PDF

Is standard?

Is it capable to render HTML, JS?

# References

http://neerc.ifmo.ru/wiki/index.php

https://tug.org/texshowcase/cheat.pdf