Dydaktyka
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Lista 0 (25 lutego 2021), grupa pwit ###### tags: `ask21` `ćwiczenia` `pwit` ## Deklaracje Gotowość rozwiązania zadania należy wyrazić poprzez postawienie X w odpowiedniej kolumnie! Jeśli pożądasz zreferować dane zadanie (co najwyżej jedno!) w trakcie dyskusji oznacz je znakiem ==X== na żółtym tle. **UWAGA: Tabelkę wolno edytować tylko wtedy, gdy jest na zielonym tle!** Tabelka zawiera tylko osoby zapisane do grupy. Osoby oczekujące proszone są o wpisanie się do osobnej tabelki poniżej. :::warning Z tej listy pojedyńczy student może otrzymać maks 2. punkty (bonusowe). Tabelka służy do poinformowania, kogo można tymi bonusami obdarzyć. ::: :::danger | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | | --------------------:| --- | --- | --- | --- |:---:|:---:| --- |:---:| |Wojciech Adamiec | X | X | X | | X | | X | X | |Kacper Bajkiewicz | | | | | | | | | |Bartłomiej Hildebrandt| | | | | | | | | |Dominik Komła | | | | | | | | | |Aleksandra Kosińska | X | X | X | | X | X | X | | |Oleś Kulcewicz | | | | | | | | | |Damian Lukas | | | | | | | | | |Michał Mikołajczyk | X | X | X | | X | | | | |Mateusz Opala | | X | X | X | X | | | | |Łukasz Orawiec | | | | | | | | | |Szymon Pielat | X | X | X | | X | | | | |Łukasz Pluta | X | X | X | X |==X==| | X | | |Kamil Puchacz | X | X | X | x | X | | | | |Magdalena Rzepka | X | X | X | | X | ==X==| | | |Cezary Stajszczyk | X | X | X | X | X | X | X | | |Jakub Szajner | | | | | | | | | |Bartosz Troszka | | | | | | | | | |Miłosz Urbanik | X | X | X | X | X | X | | | Tabelka dla osób oczekujących na zapis. | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | | --------------------:| --- | --- | --- | --- |:---:|:---:| --- |:---:| | | | | | | | | | | ::: ## Zadanie 1 :::info Autor: Michał Mikołajczyk ::: >Przekształć każdą z podanych liczb z systemu ósemkowego na system binarny, szesnastkowy i dziesiętny: - $42_8 = 100\space010_2 = 0010\space0010_2 = 22_{16} = 34_{10}$ - $255_8 = 010\space101\space101_2 = 1010\space1101_2 = AD_{16} = 173_{10}$ - $3047_8 = 011\space000\space100\space111_2= 0110\space0010\space0111_2 = 627_{16} = 1575_{10}$ - $140336_8= 001\space100\space000\space011\space011\space110_2 = 1100\space0000\space1101\space1110_2 = C0DE_{16} = 49374_{10}$ ## Zadanie 2 :::info Autor: Mateusz Opala ::: 1.2A 2.9F 3.7F+7F=FE 4.166 ![](https://i.imgur.com/16NFoK1.png) :O ## Zadanie 3 :::info Autor: Aleksandra Kosińska ::: Wyzeruj $k$-ty bit zmiennej $x$: ```c x &= ~(1<<k); ``` Ustaw $k$-ty bit zmiennej $x$: ```c x |= 1<<k; ``` Zaneguj $k$-ty bit zmiennej $x$: ```c x ^= 1<<k; ``` ## Zadanie 4 :::info Autor: Kamil Puchacz ::: ``` uint32_t A(uint_32t x, uint32_t y){ return x << y; } uint32_t B(uint_32t x, uint32_t y){ return x >> y; } uint32_t C(uint_32t x, uint32_t y){ return x & ((1 << y) - 1) } uint32_t D(uint_32t x, uint32_t y){ return (x >> y) + ((X << (32 - y)) > 0) } ``` Hipoteza: wynik = ((x+(1<<(y-1)))>>y) bierzemy liczbę dodajemy do niej połowę naszego modulo i przesuwamy bitowo o y. Uwaga: problem dla "dużych" x i y Przykład 1: x = 26 x = 0b(11010), y = 2 sufit(x/4) = 7 wynik = Przykład 2: x = 0b(11001), y = 2 problem: wynik poprawny to 7, algorytm daje odpowiedź 6 Poprawka: wynik=((x+(1<<y)-1)>>y) komentarz: x=a*(1<<y)+b dla b=0, wynik=a, dla b>0: wynik=(a*(1<<y)+b+(1<<y)-1)>>y, gdzie b+(1<<y)-1>=(1<<y),więc wynik=a+1 **Pytanie**: czy umiemy rozwiązać to zadanie dla x typu int32_t (a nie uint32_t). Czy poniższy kod działa? ``` uint32_t A(int_32t x, uint32_t y){ return x << y; } ``` Zakłady, że x*2^y mieści się w typie int32_t. Łatwiejsze pytanie. Załóżmy, że x < 0 oraz liczby x i 2*x mieszczą się w typie int32_t. Pokażemy, że 2*x jest równe x << 1. x = 0b(1a_30...a_0) x = -2^31 + a_30*2^30 + ... + a_0 * 2^0 "x << 1" = -2^31*a_30 + 2^30*a_29 + ... + 2*a_1 Gdyby a_30 było == 0 to by oznaczało, że 2x nie mieści się w int32_t. Pomysł: (x jest typu int32_t) $\lceil x/2^y \rceil=\lfloor\frac{x+(2^y - 1)}{2^y}\rfloor$ Gdy x < 0 to poniższe wyrażenie "działa": a =`(x + (1 << y) - 1) >> y` Gdy x >= 0 to trzeba je poprawić, bo "nie działa" dla "dużych" x. Poprawka b = `(x + ((1 << y) - 1U) >> y` i trzeba umieć zakodować warunek: x < 0 ? a : b | ## Zadanie 5 :::info Autor: Łukasz Pluta ::: return ((x == 0) || (x & (x - 1))); LUB ((x-1) & (1 << 31)) | (x & (x - 1)) ## Zadanie 6 :::info Autor: Magdalena Rzepka ::: **Big endian** - to forma zapisu danych, w której najbardziej znaczący bajt umieszcza się jako pierwszy. **Little endian** - to forma zapisu danych, w której najmniej znaczący bajt umieszcza się jako pierwszy. ![](https://i.imgur.com/zM2m7t1.png) ![](https://i.imgur.com/B899rY2.png) 8 bitów = 1 bajt 32 / 8 = 4 ```c uint32_t x; uint32_t first, second, third, fourth; first = (x & 0x000000ff) << 24; second = (x & 0x0000ff00) << 8; third = (x & 0x00ff0000) >> 8; fourth = (x & 0xff000000) >> 24; uint32_t answer = first | second | third | fourth; ``` 0bmaska_bitowa ## Zadanie 7 :::info Autor: Cezary Stajszczyk ::: **ASCII** - siedmio bitowy system kodowania znaków; każdej liczbie przyporządkowany jest znak. **Kody sterujące** - pierwsze 32 kody, nie odpowiadają żadnemu drukowalnemy znakowi, tylko służą do sterowania urządzeniem. Kody sterujące ASCII: - 0 - NULL - 4 - EOT (end of transmission) - 7 - sygnał dźwiękowy - 10 - przesunięcie o jeden wiersz - 12 - przesunięcie o jedną stronę ## Zadanie 8 :::info Autor: Wojciech Adamiec ::: **UTF-8** (8-bit Unicode Transformation Format) – system kodowania, wykorzystujący od 1 do 4 bajtów do zakodowania pojedynczego znaku, w pełni kompatybilny z ASCII. Jest najczęściej wykorzystywany do przechowywania napisów w plikach i komunikacji sieciowej. Tablica ASCII ma tylko 128 znaków - do wielu celów to jest zdecydowanie za mało, UTF-8 rozwiązuje ten problem. Kodowanie zależy od tego o jakim znaku mówimy. Dla odpowiednich przedziałów kodów korzystamy z tabeli: ![alt text](https://i.imgur.com/kS5LBGy.png "Logo Title Text 1") Tekst do zakodowania: *Proszę zapłacić 5€!* 50 72 6f 73 7a c4 99 20 7a 61 70 c5 82 61 63 69 c4 87 20 35 e2 82 ac 21 Dla przykładu popatrzmy na €: 1. Kod dla € to U+20AC. 2. Jest to przedział między U+0800 a U+FFFF, więc potrzebujemy 3 bajtów. 3. $20AC_{16} = 0010 \space 0000 10\space10 1100_2$. 4. Korzystamy z tabeli w taki sposób, że w miejsce każdego $x$ wstawiamy kolejne bity. 5. Dostajemy na koniec takie kodowanie: $1110 \space 0010 \space 1000 \space 0010 \space 1010 \space 1100$ 6. Co konwertujemy do systemu szesnastkowego: $1110 \space 0010 \space 1000 \space 0010 \space 1010 \space 1100 = E2 \space 82 \space AC$

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully