Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cours
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jeremy.meissner
cours
Commits
c6c066af
Verified
Commit
c6c066af
authored
3 years ago
by
orestis.malaspin
Browse files
Options
Downloads
Patches
Plain Diff
added stractures and started binary numbers
parent
09236db7
No related branches found
No related tags found
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
slides/cours_3.md
+94
-2
94 additions, 2 deletions
slides/cours_3.md
slides/figs/pointer_struct.svg
+454
-0
454 additions, 0 deletions
slides/figs/pointer_struct.svg
with
548 additions
and
2 deletions
slides/cours_3.md
+
94
−
2
View file @
c6c066af
...
...
@@ -473,7 +473,98 @@ for (int i = 0; i < NX; ++i) {
## Poster le résultat sur `Element`
# Représentation des nombres en binaire (1/N)
# Représentation des nombres (1/2)
*
Le nombre
`247`
.
## Nombres décimaux: Les nombres en base 10
+--------+--------+--------+
| $10^2$ | $10^1$ | $10^0$ |
+--------+--------+--------+
|
`2`
|
`4`
|
`7`
|
+--------+--------+--------+
$$
247 = 2
\c
dot 10^2 + 4
\c
dot 10^1 + 7
\c
dot 10^0.
$$
# Représentation des nombres (2/2)
*
Le nombre
`11110111`
.
## Nombres binaires: Les nombres en base 2
+-------+-------+-------+-------+-------+-------+-------+-------+
| $2^7$ | $2^6$ | $2^5$ | $2^4$ | $2^3$ | $2^2$ | $2^1$ | $2^0$ |
+-------+-------+-------+-------+-------+-------+-------+-------+
|
`1`
|
`1`
|
`1`
|
`1`
|
`0`
|
`1`
|
`1`
|
`1`
|
+-------+-------+-------+-------+-------+-------+-------+-------+
$$
1
\c
dot 2^7 + 1
\c
dot 2^6 +1
\c
dot 2^5 +1
\c
dot 2^4 +0
\c
dot 2^3 +1
\c
dot 2^2
+1
\c
dot 2^1 +1
\c
dot 2^0
$$
. . .
$$
= 247.
$$
# Conversion de décimal à binaire (1/N)
## Convertir 11 en binaire?
. . .
*
On décompose en puissances de 2 en partant de la plus grande possible
```
11 / 8 = 1, 11 % 8 = 3
3 / 4 = 0, 3 % 4 = 3
3 / 2 = 1, 3 % 2 = 1
1 / 1 = 1, 1 % 1 = 0
```
*
On a donc
$$
1011 \Rightarrow 1\cdot 2^3 + 0\cdot 2^2 + 1\cdot 2^1 + 1\cdot
2^0=11.
$$
# Conversion de décimal à binaire (2/N)
## Convertir un nombre arbitraire en binaire: 247?
*
Par groupe établir un algorithme.
. . .
## Algorithme
1.
Initialisation
```
C
num = 247
while (2^N < num) {
N += 1
}
```
. . .
2.
Boucle
```C
while (N >= 0) {
bit = num / 2^N
num = num % 2^N
N += 1
}
```
# TODO
## Entiers, entiers non-signés
...
...
@@ -547,7 +638,8 @@ struct fraction frac; // déclaration de frac
frac->denom = -1; // mémoire pas allouée.
```

{width=100%}

{width=50%}
# Types complexes: `struct`{.C} (5/6)
...
...
This diff is collapsed.
Click to expand it.
slides/figs/pointer_struct.svg
0 → 100644
+
454
−
0
View file @
c6c066af
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment