<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Leokohc 코딩 걸음마</title>
    <link>https://loekohcoder.tistory.com/</link>
    <description></description>
    <language>ko</language>
    <pubDate>Sun, 19 Jul 2026 20:04:52 +0900</pubDate>
    <generator>TISTORY</generator>
    <ttl>100</ttl>
    <managingEditor>loekohc</managingEditor>
    <item>
      <title>Python JPEG 사진 정보 불러오기 : pillow</title>
      <link>https://loekohcoder.tistory.com/27</link>
      <description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://pillow.readthedocs.io/en/stable/installation.html#basic-installation&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;pillow.readthedocs.io/en/stable/installation.html#basic-installation&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1606569961085&quot; contenteditable=&quot;false&quot; data-ke-type=&quot;opengraph&quot; data-og-type=&quot;website&quot; data-og-title=&quot;Installation &amp;mdash; Pillow (PIL Fork) 8.0.1 documentation&quot; data-og-description=&quot;Build flags: --disable-zlib, --disable-jpeg, --disable-tiff, --disable-freetype, --disable-lcms, --disable-webp, --disable-webpmux, --disable-jpeg2000, --disable-imagequant, --disable-xcb. Disable building the corresponding feature even if the development &quot; data-og-host=&quot;pillow.readthedocs.io&quot; data-og-source-url=&quot;https://pillow.readthedocs.io/en/stable/installation.html#basic-installation&quot; data-og-url=&quot;https://pillow.readthedocs.io/en/stable/installation.html#basic-installation&quot; data-og-image=&quot;&quot;&gt;&lt;a href=&quot;https://pillow.readthedocs.io/en/stable/installation.html#basic-installation&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://pillow.readthedocs.io/en/stable/installation.html#basic-installation&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url();&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;og-text&quot;&gt;
&lt;p class=&quot;og-title&quot;&gt;Installation &amp;mdash; Pillow (PIL Fork) 8.0.1 documentation&lt;/p&gt;
&lt;p class=&quot;og-desc&quot;&gt;Build flags: --disable-zlib, --disable-jpeg, --disable-tiff, --disable-freetype, --disable-lcms, --disable-webp, --disable-webpmux, --disable-jpeg2000, --disable-imagequant, --disable-xcb. Disable building the corresponding feature even if the development&lt;/p&gt;
&lt;p class=&quot;og-host&quot;&gt;pillow.readthedocs.io&lt;/p&gt;
&lt;/div&gt;
&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;exif 정보를 불러올 수 있는 모양&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; exif 정보는 아래와 같은 정보를 담고 있음&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.awaresystems.be/imaging/tiff/tifftags/privateifd/exif.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;www.awaresystems.be/imaging/tiff/tifftags/privateifd/exif.html&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1606569992214&quot; contenteditable=&quot;false&quot; data-ke-type=&quot;opengraph&quot; data-og-type=&quot;website&quot; data-og-title=&quot;EXIF Tags&quot; data-og-description=&quot;TIFF Tag Reference, Exif Tags Exif tags are used largely to encode additional information related to image generation by digital still cameras. Exif is the abbreviation of 'Exchangeable image file format', though this can be argued to be a misnomer, as Exi&quot; data-og-host=&quot;www.awaresystems.be&quot; data-og-source-url=&quot;https://www.awaresystems.be/imaging/tiff/tifftags/privateifd/exif.html&quot; data-og-url=&quot;https://www.awaresystems.be/imaging/tiff/tifftags/privateifd/exif.html&quot; data-og-image=&quot;&quot;&gt;&lt;a href=&quot;https://www.awaresystems.be/imaging/tiff/tifftags/privateifd/exif.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://www.awaresystems.be/imaging/tiff/tifftags/privateifd/exif.html&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url();&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;og-text&quot;&gt;
&lt;p class=&quot;og-title&quot;&gt;EXIF Tags&lt;/p&gt;
&lt;p class=&quot;og-desc&quot;&gt;TIFF Tag Reference, Exif Tags Exif tags are used largely to encode additional information related to image generation by digital still cameras. Exif is the abbreviation of 'Exchangeable image file format', though this can be argued to be a misnomer, as Exi&lt;/p&gt;
&lt;p class=&quot;og-host&quot;&gt;www.awaresystems.be&lt;/p&gt;
&lt;/div&gt;
&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;PIL 을 이용해서 jpg 파일의 정보를 출력하는 간단한 프로그램&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre id=&quot;code_1606570894772&quot; class=&quot;python&quot; style=&quot;display: block; overflow: auto; padding: 15px; color: #383a42; background-color: #f6f7f8; font-size: 14px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; font-family: Menlo, Consolas, Monaco, monospace; border: 1px solid #dddddd; margin: 20px auto 0px; cursor: default; z-index: 1; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; background-position: initial initial; background-repeat: initial initial;&quot; data-ke-language=&quot;python&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;from PIL import Image
im = Image.open('5D3_9369.JPG')
takentime = im.getexif()[36867]
print (im.format, im.size, im.mode, takentime)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;결과&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre id=&quot;code_1606570925049&quot; class=&quot;python&quot; style=&quot;display: block; overflow: auto; padding: 15px; color: #383a42; background-color: #f6f7f8; font-size: 14px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; font-family: Menlo, Consolas, Monaco, monospace; border: 1px solid #dddddd; margin: 20px auto 0px; cursor: default; z-index: 1; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; background-position: initial initial; background-repeat: initial initial;&quot; data-ke-language=&quot;python&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;JPEG (5760, 3840) RGB 2020:10:18 12:50:39&lt;/code&gt;&lt;/pre&gt;</description>
      <category>Python</category>
      <author>loekohc</author>
      <guid isPermaLink="true">https://loekohcoder.tistory.com/27</guid>
      <comments>https://loekohcoder.tistory.com/27#entry27comment</comments>
      <pubDate>Sat, 28 Nov 2020 22:42:20 +0900</pubDate>
    </item>
    <item>
      <title>Macbook Catalina Python 개발 환경 잡기</title>
      <link>https://loekohcoder.tistory.com/26</link>
      <description>&lt;p&gt;&amp;nbsp;- Visual Studio Code&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://code.visualstudio.com&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;code.visualstudio.com&lt;/a&gt;&lt;/p&gt;
&lt;figure id=&quot;og_1606568804407&quot; contenteditable=&quot;false&quot; data-ke-type=&quot;opengraph&quot; data-og-type=&quot;website&quot; data-og-title=&quot;Visual Studio Code - Code Editing. Redefined&quot; data-og-description=&quot;Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications.&amp;nbsp; Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.&quot; data-og-host=&quot;code.visualstudio.com&quot; data-og-source-url=&quot;https://code.visualstudio.com&quot; data-og-url=&quot;https://code.visualstudio.com/&quot; data-og-image=&quot;https://scrap.kakaocdn.net/dn/bL28LY/hyIoWzS0rv/HpWQvb1hzBVRyBWkMXGHD0/img.png?width=1012&amp;amp;height=506&amp;amp;face=0_0_1012_506&quot;&gt;&lt;a href=&quot;https://code.visualstudio.com&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; data-source-url=&quot;https://code.visualstudio.com&quot;&gt;
&lt;div class=&quot;og-image&quot; style=&quot;background-image: url('https://scrap.kakaocdn.net/dn/bL28LY/hyIoWzS0rv/HpWQvb1hzBVRyBWkMXGHD0/img.png?width=1012&amp;amp;height=506&amp;amp;face=0_0_1012_506');&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;og-text&quot;&gt;
&lt;p class=&quot;og-title&quot;&gt;Visual Studio Code - Code Editing. Redefined&lt;/p&gt;
&lt;p class=&quot;og-desc&quot;&gt;Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications.&amp;nbsp; Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.&lt;/p&gt;
&lt;p class=&quot;og-host&quot;&gt;code.visualstudio.com&lt;/p&gt;
&lt;/div&gt;
&lt;/a&gt;&lt;/figure&gt;
&lt;p&gt;- brew&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://brew.sh&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;brew.sh&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;- Python3.8.2&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://medium.com/front-end-weekly/how-to-install-the-latest-python-3-on-mac-with-no-issues-5db0045e1429&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;medium.com/front-end-weekly/how-to-install-the-latest-python-3-on-mac-with-no-issues-5db0045e1429&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;- pip&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.geeksforgeeks.org/how-to-install-pip-in-macos/#:~:text=pip%20can%20be%20downloaded%20and%20installed%20using%20command-line,3%20Voila%21%20pip%20is%20now%20installed%20on%20&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;www.geeksforgeeks.org/how-to-install-pip-in-macos/#:~:text=pip%20can%20be%20downloaded%20and%20installed%20using%20command-line,3%20Voila%21%20pip%20is%20now%20installed%20on%20&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;- Visual Studio Code 에서 python extension 들 설치&lt;/p&gt;
&lt;p&gt;- Visual Studio Code 에서 python interpreter 설정&lt;/p&gt;
&lt;p&gt;&amp;nbsp;: ⌘+⇧+p&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;: Python: Select Interpreter&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignCenter&quot; data-filename=&quot;스크린샷 2020-11-28 오후 10.09.08.png&quot; data-origin-width=&quot;1226&quot; data-origin-height=&quot;822&quot; data-ke-mobilestyle=&quot;widthContent&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/1OT7P/btqOtEvr4sv/AkklOfTTqtHBT7EfOrMTlK/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/1OT7P/btqOtEvr4sv/AkklOfTTqtHBT7EfOrMTlK/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/1OT7P/btqOtEvr4sv/AkklOfTTqtHBT7EfOrMTlK/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2F1OT7P%2FbtqOtEvr4sv%2FAkklOfTTqtHBT7EfOrMTlK%2Fimg.png&quot; data-filename=&quot;스크린샷 2020-11-28 오후 10.09.08.png&quot; data-origin-width=&quot;1226&quot; data-origin-height=&quot;822&quot; data-ke-mobilestyle=&quot;widthContent&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;사용할 python version 선택&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignCenter&quot; data-filename=&quot;스크린샷 2020-11-28 오후 10.09.22.png&quot; data-origin-width=&quot;1200&quot; data-origin-height=&quot;544&quot; data-ke-mobilestyle=&quot;widthContent&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/dEr8ld/btqOxq3Pjf2/AWwHgwp592KXPGTgzKQm81/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/dEr8ld/btqOxq3Pjf2/AWwHgwp592KXPGTgzKQm81/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/dEr8ld/btqOxq3Pjf2/AWwHgwp592KXPGTgzKQm81/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FdEr8ld%2FbtqOxq3Pjf2%2FAWwHgwp592KXPGTgzKQm81%2Fimg.png&quot; data-filename=&quot;스크린샷 2020-11-28 오후 10.09.22.png&quot; data-origin-width=&quot;1200&quot; data-origin-height=&quot;544&quot; data-ke-mobilestyle=&quot;widthContent&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;- 번외 : Mac Terminal 용 Dracula theme 설치&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignCenter&quot; data-filename=&quot;스크린샷 2020-11-28 오후 9.56.14.png&quot; data-origin-width=&quot;1140&quot; data-origin-height=&quot;766&quot; data-ke-mobilestyle=&quot;widthContent&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/S7Hgh/btqOvRAA5rH/32Rc4afNHM9VkRO1YlhfwK/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/S7Hgh/btqOvRAA5rH/32Rc4afNHM9VkRO1YlhfwK/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/S7Hgh/btqOvRAA5rH/32Rc4afNHM9VkRO1YlhfwK/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FS7Hgh%2FbtqOvRAA5rH%2F32Rc4afNHM9VkRO1YlhfwK%2Fimg.png&quot; data-filename=&quot;스크린샷 2020-11-28 오후 9.56.14.png&quot; data-origin-width=&quot;1140&quot; data-origin-height=&quot;766&quot; data-ke-mobilestyle=&quot;widthContent&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;</description>
      <category>Python</category>
      <author>loekohc</author>
      <guid isPermaLink="true">https://loekohcoder.tistory.com/26</guid>
      <comments>https://loekohcoder.tistory.com/26#entry26comment</comments>
      <pubDate>Sat, 28 Nov 2020 22:14:40 +0900</pubDate>
    </item>
    <item>
      <title>Python 연습 프로젝트 1</title>
      <link>https://loekohcoder.tistory.com/25</link>
      <description>&lt;h3 data-ke-size=&quot;size23&quot;&gt;원하는 기능&lt;/h3&gt;
&lt;p data-ke-size=&quot;size14&quot;&gt;특정 폴더에 있는 사진파일을 읽어 년도 아래 월 폴더를 만들어 이동시키기&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h3 data-ke-size=&quot;size23&quot;&gt;연습 목록&lt;/h3&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;1. Python 으로 사진파일 정보 중 촬영날짜 읽어오기&lt;/h4&gt;
&lt;p&gt;&lt;a href=&quot;https://loekohcoder.tistory.com/27&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;loekohcoder.tistory.com/27&lt;/a&gt;&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;2. Python 으로 디렉터리 확인 및 생성&lt;/h4&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4 data-ke-size=&quot;size20&quot;&gt;3. Python 으로 파일 이동&lt;/h4&gt;</description>
      <category>Python</category>
      <category>coding</category>
      <category>python</category>
      <category>연습</category>
      <author>loekohc</author>
      <guid isPermaLink="true">https://loekohcoder.tistory.com/25</guid>
      <comments>https://loekohcoder.tistory.com/25#entry25comment</comments>
      <pubDate>Sat, 28 Nov 2020 15:43:43 +0900</pubDate>
    </item>
    <item>
      <title>csh: Event Not Found</title>
      <link>https://loekohcoder.tistory.com/24</link>
      <description>&lt;p data-ke-size=&quot;size16&quot; style=&quot;text-align: justify;&quot;&gt;somthing.csh 파일 수행 시&lt;br&gt;0: Event Not Found 가 나오는 경우&lt;br&gt;&lt;br&gt;&lt;br&gt;something.csh 파일 첫 줄에&lt;br&gt;#!\bin\csh&lt;br&gt;이 있는 경우&lt;br&gt;echo 나 print 로 출력시 출력하는 문구에 ! 가 있으면 위의 에러가 발생 됨.&lt;br&gt;! 를 출력하고 싶으면&lt;br&gt;echo &quot;\!&quot; 를 사용할 것.&lt;br&gt;아니면 echo '!' 를 사용할 것 &lt;/p&gt;</description>
      <category>etc.</category>
      <category>csh</category>
      <category>eventnotfound</category>
      <author>loekohc</author>
      <guid isPermaLink="true">https://loekohcoder.tistory.com/24</guid>
      <comments>https://loekohcoder.tistory.com/24#entry24comment</comments>
      <pubDate>Tue, 24 Nov 2020 11:11:22 +0900</pubDate>
    </item>
    <item>
      <title>VS code</title>
      <link>https://loekohcoder.tistory.com/23</link>
      <description>&lt;p&gt;VS Code 가 핫하다길래 장비병 환자인 내가 또 안깔아볼 수는 없지.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 900px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/992D49345BDC4D630E&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F992D49345BDC4D630E&quot; width=&quot;900&quot; height=&quot;559&quot; filename=&quot;스크린샷 2018-11-02 오후 10.10.14.png&quot; filemime=&quot;image/png&quot; style=&quot;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Atom 을 바로 삭제함.&lt;br /&gt;&lt;/p&gt;</description>
      <category>etc.</category>
      <author>loekohc</author>
      <guid isPermaLink="true">https://loekohcoder.tistory.com/23</guid>
      <comments>https://loekohcoder.tistory.com/23#entry23comment</comments>
      <pubDate>Fri, 2 Nov 2018 22:13:28 +0900</pubDate>
    </item>
    <item>
      <title>Tkinter 를 이용한 시계</title>
      <link>https://loekohcoder.tistory.com/22</link>
      <description>&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(185, 185, 185);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;# clock.py&amp;nbsp; By Anton Vredegoor (anton.vredegoor@gmail.com)&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(185, 185, 185);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;# last edit: july 2009,&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(185, 185, 185);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;# license: GPL&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(185, 185, 185);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;# enjoy!&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66); min-height: 13px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(83, 154, 51);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(83, 154, 51);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;A very simple&amp;nbsp; clock.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(83, 154, 51); min-height: 13px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(83, 154, 51);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;The program transforms worldcoordinates into screencoordinates&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(83, 154, 51);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;and vice versa according to an algorithm found in: &quot;Programming&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(83, 154, 51);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;principles in computer graphics&quot; by Leendert Ammeraal.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(83, 154, 51); min-height: 13px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(83, 154, 51);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&quot;&quot;&quot;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66); min-height: 13px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; Tkinter &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; *&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; time &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; localtime&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; datetime &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; timedelta,datetime&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; sys, types, os&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66); min-height: 13px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;_inidle = type(sys.stdin) == types.InstanceType &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;and&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; \&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;&amp;nbsp; sys.stdin.__class__.__name__ == &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;'PyShell'&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66); min-height: 13px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; transformer:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66); min-height: 13px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; __init__(self, world, viewport):&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.world = world&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.viewport = viewport&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66); min-height: 13px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66); min-height: 13px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; clock:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66); min-height: 13px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; __init__(self,root,deltahours = &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;):&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.world &amp;nbsp; &amp;nbsp; &amp;nbsp; = [&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;-1&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;-1&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;]&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.bgcolor &amp;nbsp; &amp;nbsp; = &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;'#ffffff'&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.timecolor &amp;nbsp; = &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;'#000000'&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self._ALL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;'all'&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.pad &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;25&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.root&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = root&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WIDTH, HEIGHT = &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;200&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;200&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; root.bind(&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #539a33&quot;&gt;&quot;&amp;lt;Escape&amp;gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;lambda&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; _ : root.destroy())&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.delta = timedelta(hours = deltahours) &amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.canvas = Canvas(root,&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; width &amp;nbsp; &amp;nbsp; &amp;nbsp; = WIDTH,&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; height&amp;nbsp; &amp;nbsp; &amp;nbsp; = HEIGHT,&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; background&amp;nbsp; = self.bgcolor)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; viewport = (self.pad,self.pad,WIDTH-self.pad,HEIGHT-self.pad)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.T = transformer(self.world,viewport)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.root.title(&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;'Clock'&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.canvas.bind(&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #539a33&quot;&gt;&quot;&amp;lt;Configure&amp;gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;,self.configure())&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.canvas.pack(fill=BOTH, expand=YES)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.poll()&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66); min-height: 13px;&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; configure(self):&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.redraw()&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66); min-height: 13px;&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; redraw(self):&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sc = self.canvas&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sc.delete(self._ALL)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; width = sc.winfo_width()&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; height =sc.winfo_height()&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sc.create_rectangle([[&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;],[width,height]], fill = self.bgcolor, tag = self._ALL)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66); min-height: 13px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; viewport = (self.pad,self.pad,width-self.pad,height-self.pad)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.T = transformer(self.world,viewport)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.paintgrafics()&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66); min-height: 13px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; paintgrafics(self):&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.painthms()&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66); min-height: 13px;&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; painthms(self):&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sc = self.canvas&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; T = datetime.timetuple(datetime.utcnow()-self.delta)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x,x,x,h,m,s,x,x,x = T&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(185, 185, 185);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #424242&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;#self.root.title('%02i:%02i:%02i' %(h,m,s))&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; now = datetime.now()&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; curTime = now.strftime(&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;'%H:%M:%S'&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; workTime = now-startTime;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sc.create_text(&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;,fill=&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #539a33&quot;&gt;&quot;black&quot;&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;,text=&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #539a33&quot;&gt;&quot;NOW&amp;nbsp; :&quot;&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;+curTime)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sc.create_text(&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;,fill=&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #539a33&quot;&gt;&quot;orange&quot;&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;,text=&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #539a33&quot;&gt;&quot;START:&quot;&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;+startTime.strftime(&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;'%H:%M:%S'&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;))&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; (workTime.seconds &amp;gt; &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;) :&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sc.create_text(&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;50&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;,fill=&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #539a33&quot;&gt;&quot;magenta&quot;&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;,text=&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #539a33&quot;&gt;&quot;Go to HOME!!&quot;&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; (workTime.seconds &amp;gt; &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;) :&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sc.create_text(&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;70&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;,fill=&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #539a33&quot;&gt;&quot;magenta&quot;&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;,text=&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #539a33&quot;&gt;&quot;15,000!!&quot;&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; poll(self):&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.configure()&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.root.after(&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;200&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;,self.poll)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66); min-height: 13px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; main():&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; root= Tk()&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;global&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; startTime&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; startTime = datetime.now()&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; clock(root,deltahours = &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;-9&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;not&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; _inidle:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; root.mainloop()&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66); min-height: 13px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #406ea0&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt; __name__==&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures; color: #bb7832&quot;&gt;'__main__'&lt;/span&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;:&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 12px; line-height: normal; font-family: Menlo; color: rgb(164, 140, 83);&quot;&gt;































































































&lt;/p&gt;&lt;p style=&quot;margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);&quot;&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&amp;nbsp; main()&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;span style=&quot;font-variant-ligatures: no-common-ligatures&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>Python</category>
      <author>loekohc</author>
      <guid isPermaLink="true">https://loekohcoder.tistory.com/22</guid>
      <comments>https://loekohcoder.tistory.com/22#entry22comment</comments>
      <pubDate>Tue, 27 Jun 2017 22:42:17 +0900</pubDate>
    </item>
    <item>
      <title>Fixed Point Prototype</title>
      <link>https://loekohcoder.tistory.com/21</link>
      <description>&lt;div style=&quot;font-family: 'Lucida Grande', 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Lucida Sans Unicode', Helvetica, Arial, sans-serif; font-size: 0.9em; overflow-x: hidden; overflow-y: auto; margin: 0px !important; padding: 5px 20px 26px !important; background-color: rgb(255, 255, 255);font-family: 'Hiragino Sans GB', 'Microsoft YaHei', STHeiti, SimSun, 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', 'Segoe UI', AppleSDGothicNeo-Medium, 'Malgun Gothic', Verdana, Tahoma, sans-serif; padding: 20px;padding: 20px; color: rgb(34, 34, 34); font-size: 15px; font-family: 'Roboto Condensed', Tauri, 'Hiragino Sans GB', 'Microsoft YaHei', STHeiti, SimSun, 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', 'Segoe UI', AppleSDGothicNeo-Medium, 'Malgun Gothic', Verdana, Tahoma, sans-serif; line-height: 1.6; -webkit-font-smoothing: antialiased; background: rgb(255, 255, 255);&quot;&gt;&lt;pre style=&quot;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: rgb(101, 123, 131); background: rgb(253, 246, 227);&quot;&gt;&lt;code class=&quot;cpp&quot; data-origin=&quot;&lt;pre&gt;&lt;code class=&amp;quot;cpp&amp;quot;&gt;#include &amp;amp;lt;stdio.h&amp;amp;gt;
#include &amp;amp;lt;math.h&amp;amp;gt;
#include &amp;amp;lt;stdlib.h&amp;amp;gt;
#include &amp;amp;lt;iostream&amp;amp;gt;
#include &amp;amp;lt;iomanip&amp;amp;gt;
#include &amp;quot;awgn.h&amp;quot;

using namespace std;
// fixed-point header file
// Qm.f
// m: the number of bits for integer
// f: the number of bits for fraction 

typedef signed short fx_t;

#define M 3  // m
#define F 2  // f



#define F_MAX ( ( 1 &amp;amp;lt;&amp;amp;lt; (M+F) ) - 1 )
#define F_MIN ( -1 * ( 1&amp;amp;lt;&amp;amp;lt;(M+F) ))
#define Fl2Fx(x) (fx_t) (x &amp;amp;gt;= 0) ? ( (x * (1 &amp;amp;lt;&amp;amp;lt; F)) + 0.5 ) : ( (x * (1 &amp;amp;lt;&amp;amp;lt; F)) - 0.5 )    //floating to fixed-point (using integer)
#define Fx2Fl(x)  (((float)x)/(1 &amp;amp;lt;&amp;amp;lt; F))


fx_t sat_check(fx_t x)
{
    if (x &amp;amp;gt; F_MAX)
        return F_MAX;
    else if (x &amp;amp;lt; F_MIN)
        return F_MIN;
    else
        return x;
}

int main(void){

    float R = 0.5;
    double snr = 3.0;
    double sigma;

    double max = 0;


    const int N = 100; //length

    float sample[N] = { 0 };
    fx_t f_sample[N] = { 0 };  //fixed point
    fx_t q_sample[N] = { 0 };  // quantized

    int q_bit = 4; // the number of bit for quatization
    int q_max = pow(2, q_bit) - 1;

    //fixed-point 에서의 maximum 값, overflow 처리 필요.

    cout &amp;amp;lt;&amp;amp;lt; &amp;quot;Max. Fixed-Point :&amp;quot; &amp;amp;lt;&amp;amp;lt; F_MAX &amp;amp;lt;&amp;amp;lt; endl;
    cout &amp;amp;lt;&amp;amp;lt; &amp;quot;Min. Fixed-Point :&amp;quot; &amp;amp;lt;&amp;amp;lt; F_MIN &amp;amp;lt;&amp;amp;lt; endl;
    //getchar();
    sigma = pow(10, -0.05*snr) / sqrt(2 * R);

    //cout &amp;amp;lt;&amp;amp;lt; &amp;quot;Orig.\t\tFixed\t\tFx_int\t\tFx_fl&amp;quot; &amp;amp;lt;&amp;amp;lt; endl;
    for (int i = 0; i &amp;amp;lt; N; i++)
    {
        float temp;
        sample[i] = 1 + gaussian(0, sigma);

        f_sample[i] = Fl2Fx(sample[i]);
        //temp = (int)(sample[i] * (1 &amp;amp;lt;&amp;amp;lt; F));
        //temp = (float)temp / (1 &amp;amp;lt;&amp;amp;lt; F);
        //cout &amp;amp;lt;&amp;amp;lt; setw(8) &amp;amp;lt;&amp;amp;lt; sample[i] &amp;amp;lt;&amp;amp;lt; &amp;quot;\t&amp;quot; &amp;amp;lt;&amp;amp;lt; temp &amp;amp;lt;&amp;amp;lt; &amp;quot;\t\t&amp;quot;;

        //printf(&amp;quot;%d\t\t&amp;quot;, f_sample[i]);
        //printf(&amp;quot;%f\n&amp;quot;, Fx2Fl(f_sample[i]));
        //putchar('\n');
    }
    cout &amp;amp;lt;&amp;amp;lt; &amp;quot;F_samp\t\tOrig.\t\tSat&amp;quot; &amp;amp;lt;&amp;amp;lt; endl;
    fx_t temp = 0;
    for (int i = 0; i &amp;amp;lt; N; i++)
    {

        temp += f_sample[i];
        cout &amp;amp;lt;&amp;amp;lt; f_sample[i]&amp;amp;lt;&amp;amp;lt;&amp;quot;\t\t&amp;quot;&amp;amp;lt;&amp;amp;lt;temp &amp;amp;lt;&amp;amp;lt; &amp;quot;\t\t&amp;quot; &amp;amp;lt;&amp;amp;lt; sat_check(temp) &amp;amp;lt;&amp;amp;lt; endl;
        getchar();
    }
    cout &amp;amp;lt;&amp;amp;lt; endl;
    cout &amp;amp;lt;&amp;amp;lt; &amp;quot;maximum:  &amp;quot; &amp;amp;lt;&amp;amp;lt; max &amp;amp;lt;&amp;amp;lt; endl;

    return 0;
}
&lt;/code&gt;&lt;/pre&gt;&quot; style=&quot;border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;&quot;&gt;&lt;span class=&quot;hljs-preprocessor&quot; style=&quot;color: rgb(203, 75, 22);&quot;&gt;#&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);color: rgb(203, 75, 22);&quot;&gt;include&lt;/span&gt; &amp;lt;stdio.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hljs-preprocessor&quot; style=&quot;color: rgb(203, 75, 22);&quot;&gt;#&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);color: rgb(203, 75, 22);&quot;&gt;include&lt;/span&gt; &amp;lt;math.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hljs-preprocessor&quot; style=&quot;color: rgb(203, 75, 22);&quot;&gt;#&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);color: rgb(203, 75, 22);&quot;&gt;include&lt;/span&gt; &amp;lt;stdlib.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hljs-preprocessor&quot; style=&quot;color: rgb(203, 75, 22);&quot;&gt;#&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);color: rgb(203, 75, 22);&quot;&gt;include&lt;/span&gt; &amp;lt;iostream&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hljs-preprocessor&quot; style=&quot;color: rgb(203, 75, 22);&quot;&gt;#&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);color: rgb(203, 75, 22);&quot;&gt;include&lt;/span&gt; &amp;lt;iomanip&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hljs-preprocessor&quot; style=&quot;color: rgb(203, 75, 22);&quot;&gt;#&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);color: rgb(203, 75, 22);&quot;&gt;include&lt;/span&gt; &quot;awgn.h&quot;&lt;/span&gt;

&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot; style=&quot;color: rgb(38, 139, 210);&quot;&gt;std&lt;/span&gt;;
&lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;// fixed-point header file&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;// Qm.f&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;// m: the number of bits for integer&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;// f: the number of bits for fraction &lt;/span&gt;

&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;typedef&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;signed&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;short&lt;/span&gt; fx_t;

&lt;span class=&quot;hljs-preprocessor&quot; style=&quot;color: rgb(203, 75, 22);&quot;&gt;#&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);color: rgb(203, 75, 22);&quot;&gt;define&lt;/span&gt; M 3  &lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;// m&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;hljs-preprocessor&quot; style=&quot;color: rgb(203, 75, 22);&quot;&gt;#&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);color: rgb(203, 75, 22);&quot;&gt;define&lt;/span&gt; F 2  &lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;// f&lt;/span&gt;&lt;/span&gt;



&lt;span class=&quot;hljs-preprocessor&quot; style=&quot;color: rgb(203, 75, 22);&quot;&gt;#&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);color: rgb(203, 75, 22);&quot;&gt;define&lt;/span&gt; F_MAX ( ( 1 &amp;lt;&amp;lt; (M+F) ) - 1 )&lt;/span&gt;
&lt;span class=&quot;hljs-preprocessor&quot; style=&quot;color: rgb(203, 75, 22);&quot;&gt;#&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);color: rgb(203, 75, 22);&quot;&gt;define&lt;/span&gt; F_MIN ( -1 * ( 1&amp;lt;&amp;lt;(M+F) ))&lt;/span&gt;
&lt;span class=&quot;hljs-preprocessor&quot; style=&quot;color: rgb(203, 75, 22);&quot;&gt;#&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);color: rgb(203, 75, 22);&quot;&gt;define&lt;/span&gt; Fl2Fx(x) (fx_t) (x &amp;gt;= 0) ? ( (x * (1 &amp;lt;&amp;lt; F)) + 0.5 ) : ( (x * (1 &amp;lt;&amp;lt; F)) - 0.5 )    &lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;//floating to fixed-point (using integer)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;hljs-preprocessor&quot; style=&quot;color: rgb(203, 75, 22);&quot;&gt;#&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);color: rgb(203, 75, 22);&quot;&gt;define&lt;/span&gt; Fx2Fl(x)  (((float)x)/(1 &amp;lt;&amp;lt; F))&lt;/span&gt;


&lt;span class=&quot;hljs-function&quot;&gt;fx_t &lt;span class=&quot;hljs-title&quot; style=&quot;color: rgb(38, 139, 210);&quot;&gt;sat_check&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(fx_t x)&lt;/span&gt;
&lt;/span&gt;{
    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt; (x &amp;gt; F_MAX)
        &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;return&lt;/span&gt; F_MAX;
    &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hljs-title&quot; style=&quot;color: rgb(38, 139, 210);&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-params&quot;&gt;(x &amp;lt; F_MIN)&lt;/span&gt;
        return F_MIN&lt;/span&gt;;
    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;else&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;return&lt;/span&gt; x;
}

&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-title&quot; style=&quot;color: rgb(38, 139, 210);&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;void&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;{

    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;float&lt;/span&gt; R = &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;0.5&lt;/span&gt;;
    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;double&lt;/span&gt; snr = &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;3.0&lt;/span&gt;;
    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;double&lt;/span&gt; sigma;

    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;double&lt;/span&gt; max = &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;;


    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int&lt;/span&gt; N = &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;100&lt;/span&gt;; &lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;//length&lt;/span&gt;

    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;float&lt;/span&gt; sample[N] = { &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt; };
    fx_t f_sample[N] = { &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt; };  &lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;//fixed point&lt;/span&gt;
    fx_t q_sample[N] = { &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt; };  &lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;// quantized&lt;/span&gt;

    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int&lt;/span&gt; q_bit = &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;4&lt;/span&gt;; &lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;// the number of bit for quatization&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int&lt;/span&gt; q_max = &lt;span class=&quot;hljs-built_in&quot; style=&quot;color: rgb(38, 139, 210);&quot;&gt;pow&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;2&lt;/span&gt;, q_bit) - &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt;;

    &lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;//fixed-point 에서의 maximum 값, overflow 처리 필요.&lt;/span&gt;

    &lt;span class=&quot;hljs-built_in&quot; style=&quot;color: rgb(38, 139, 210);&quot;&gt;cout&lt;/span&gt; &amp;lt;&amp;lt; &lt;span class=&quot;hljs-string&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;&quot;Max. Fixed-Point :&quot;&lt;/span&gt; &amp;lt;&amp;lt; F_MAX &amp;lt;&amp;lt; endl;
    &lt;span class=&quot;hljs-built_in&quot; style=&quot;color: rgb(38, 139, 210);&quot;&gt;cout&lt;/span&gt; &amp;lt;&amp;lt; &lt;span class=&quot;hljs-string&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;&quot;Min. Fixed-Point :&quot;&lt;/span&gt; &amp;lt;&amp;lt; F_MIN &amp;lt;&amp;lt; endl;
    &lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;//getchar();&lt;/span&gt;
    sigma = &lt;span class=&quot;hljs-built_in&quot; style=&quot;color: rgb(38, 139, 210);&quot;&gt;pow&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;10&lt;/span&gt;, -&lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;0.05&lt;/span&gt;*snr) / &lt;span class=&quot;hljs-built_in&quot; style=&quot;color: rgb(38, 139, 210);&quot;&gt;sqrt&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;2&lt;/span&gt; * R);

    &lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;//cout &amp;lt;&amp;lt; &quot;Orig.\t\tFixed\t\tFx_int\t\tFx_fl&quot; &amp;lt;&amp;lt; endl;&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int&lt;/span&gt; i = &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;; i &amp;lt; N; i++)
    {
        &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;float&lt;/span&gt; temp;
        sample[i] = &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt; + gaussian(&lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;, sigma);

        f_sample[i] = Fl2Fx(sample[i]);
        &lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;//temp = (int)(sample[i] * (1 &amp;lt;&amp;lt; F));&lt;/span&gt;
        &lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;//temp = (float)temp / (1 &amp;lt;&amp;lt; F);&lt;/span&gt;
        &lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;//cout &amp;lt;&amp;lt; setw(8) &amp;lt;&amp;lt; sample[i] &amp;lt;&amp;lt; &quot;\t&quot; &amp;lt;&amp;lt; temp &amp;lt;&amp;lt; &quot;\t\t&quot;;&lt;/span&gt;

        &lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;//printf(&quot;%d\t\t&quot;, f_sample[i]);&lt;/span&gt;
        &lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;//printf(&quot;%f\n&quot;, Fx2Fl(f_sample[i]));&lt;/span&gt;
        &lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;//putchar('\n');&lt;/span&gt;
    }
    &lt;span class=&quot;hljs-built_in&quot; style=&quot;color: rgb(38, 139, 210);&quot;&gt;cout&lt;/span&gt; &amp;lt;&amp;lt; &lt;span class=&quot;hljs-string&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;&quot;F_samp\t\tOrig.\t\tSat&quot;&lt;/span&gt; &amp;lt;&amp;lt; endl;
    fx_t temp = &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;;
    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int&lt;/span&gt; i = &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;; i &amp;lt; N; i++)
    {

        temp += f_sample[i];
        &lt;span class=&quot;hljs-built_in&quot; style=&quot;color: rgb(38, 139, 210);&quot;&gt;cout&lt;/span&gt; &amp;lt;&amp;lt; f_sample[i]&amp;lt;&amp;lt;&lt;span class=&quot;hljs-string&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;&quot;\t\t&quot;&lt;/span&gt;&amp;lt;&amp;lt;temp &amp;lt;&amp;lt; &lt;span class=&quot;hljs-string&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;&quot;\t\t&quot;&lt;/span&gt; &amp;lt;&amp;lt; sat_check(temp) &amp;lt;&amp;lt; endl;
        getchar();
    }
    &lt;span class=&quot;hljs-built_in&quot; style=&quot;color: rgb(38, 139, 210);&quot;&gt;cout&lt;/span&gt; &amp;lt;&amp;lt; endl;
    &lt;span class=&quot;hljs-built_in&quot; style=&quot;color: rgb(38, 139, 210);&quot;&gt;cout&lt;/span&gt; &amp;lt;&amp;lt; &lt;span class=&quot;hljs-string&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;&quot;maximum:  &quot;&lt;/span&gt; &amp;lt;&amp;lt; max &amp;lt;&amp;lt; endl;

    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;;
}&lt;/code&gt;&lt;code class=&quot;cpp&quot; data-origin=&quot;&lt;pre&gt;&lt;code class=&amp;quot;cpp&amp;quot;&gt;#include &amp;amp;lt;stdio.h&amp;amp;gt;
#include &amp;amp;lt;math.h&amp;amp;gt;
#include &amp;amp;lt;stdlib.h&amp;amp;gt;
#include &amp;amp;lt;iostream&amp;amp;gt;
#include &amp;amp;lt;iomanip&amp;amp;gt;
#include &amp;quot;awgn.h&amp;quot;

using namespace std;
// fixed-point header file
// Qm.f
// m: the number of bits for integer
// f: the number of bits for fraction 

typedef signed short fx_t;

#define M 3  // m
#define F 2  // f



#define F_MAX ( ( 1 &amp;amp;lt;&amp;amp;lt; (M+F) ) - 1 )
#define F_MIN ( -1 * ( 1&amp;amp;lt;&amp;amp;lt;(M+F) ))
#define Fl2Fx(x) (fx_t) (x &amp;amp;gt;= 0) ? ( (x * (1 &amp;amp;lt;&amp;amp;lt; F)) + 0.5 ) : ( (x * (1 &amp;amp;lt;&amp;amp;lt; F)) - 0.5 )    //floating to fixed-point (using integer)
#define Fx2Fl(x)  (((float)x)/(1 &amp;amp;lt;&amp;amp;lt; F))


fx_t sat_check(fx_t x)
{
    if (x &amp;amp;gt; F_MAX)
        return F_MAX;
    else if (x &amp;amp;lt; F_MIN)
        return F_MIN;
    else
        return x;
}

int main(void){

    float R = 0.5;
    double snr = 3.0;
    double sigma;

    double max = 0;


    const int N = 100; //length

    float sample[N] = { 0 };
    fx_t f_sample[N] = { 0 };  //fixed point
    fx_t q_sample[N] = { 0 };  // quantized

    int q_bit = 4; // the number of bit for quatization
    int q_max = pow(2, q_bit) - 1;

    //fixed-point 에서의 maximum 값, overflow 처리 필요.

    cout &amp;amp;lt;&amp;amp;lt; &amp;quot;Max. Fixed-Point :&amp;quot; &amp;amp;lt;&amp;amp;lt; F_MAX &amp;amp;lt;&amp;amp;lt; endl;
    cout &amp;amp;lt;&amp;amp;lt; &amp;quot;Min. Fixed-Point :&amp;quot; &amp;amp;lt;&amp;amp;lt; F_MIN &amp;amp;lt;&amp;amp;lt; endl;
    //getchar();
    sigma = pow(10, -0.05*snr) / sqrt(2 * R);

    //cout &amp;amp;lt;&amp;amp;lt; &amp;quot;Orig.\t\tFixed\t\tFx_int\t\tFx_fl&amp;quot; &amp;amp;lt;&amp;amp;lt; endl;
    for (int i = 0; i &amp;amp;lt; N; i++)
    {
        float temp;
        sample[i] = 1 + gaussian(0, sigma);

        f_sample[i] = Fl2Fx(sample[i]);
        //temp = (int)(sample[i] * (1 &amp;amp;lt;&amp;amp;lt; F));
        //temp = (float)temp / (1 &amp;amp;lt;&amp;amp;lt; F);
        //cout &amp;amp;lt;&amp;amp;lt; setw(8) &amp;amp;lt;&amp;amp;lt; sample[i] &amp;amp;lt;&amp;amp;lt; &amp;quot;\t&amp;quot; &amp;amp;lt;&amp;amp;lt; temp &amp;amp;lt;&amp;amp;lt; &amp;quot;\t\t&amp;quot;;

        //printf(&amp;quot;%d\t\t&amp;quot;, f_sample[i]);
        //printf(&amp;quot;%f\n&amp;quot;, Fx2Fl(f_sample[i]));
        //putchar('\n');
    }
    cout &amp;amp;lt;&amp;amp;lt; &amp;quot;F_samp\t\tOrig.\t\tSat&amp;quot; &amp;amp;lt;&amp;amp;lt; endl;
    fx_t temp = 0;
    for (int i = 0; i &amp;amp;lt; N; i++)
    {

        temp += f_sample[i];
        cout &amp;amp;lt;&amp;amp;lt; f_sample[i]&amp;amp;lt;&amp;amp;lt;&amp;quot;\t\t&amp;quot;&amp;amp;lt;&amp;amp;lt;temp &amp;amp;lt;&amp;amp;lt; &amp;quot;\t\t&amp;quot; &amp;amp;lt;&amp;amp;lt; sat_check(temp) &amp;amp;lt;&amp;amp;lt; endl;
        getchar();
    }
    cout &amp;amp;lt;&amp;amp;lt; endl;
    cout &amp;amp;lt;&amp;amp;lt; &amp;quot;maximum:  &amp;quot; &amp;amp;lt;&amp;amp;lt; max &amp;amp;lt;&amp;amp;lt; endl;

    return 0;
}
&lt;/code&gt;&lt;/pre&gt;&quot; style=&quot;border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;&quot;&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block;   height: auto; max-width: 100%;&quot;&gt;&lt;a href=&quot;https://t1.daumcdn.net/cfile/tistory/2207B73757089FA31F&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;https://i1.daumcdn.net/cfs.tistory/v/0/blog/image/extension/unknown.gif&quot; style=&quot;vertical-align: middle;&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot;/&gt;fixed_point_proto.md&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
      <category>C and C++</category>
      <author>loekohc</author>
      <guid isPermaLink="true">https://loekohcoder.tistory.com/21</guid>
      <comments>https://loekohcoder.tistory.com/21#entry21comment</comments>
      <pubDate>Sat, 9 Apr 2016 15:21:50 +0900</pubDate>
    </item>
    <item>
      <title>Fixed-point in C/C++</title>
      <link>https://loekohcoder.tistory.com/20</link>
      <description>&lt;div style=&quot;font-family: 'Lucida Grande', 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Lucida Sans Unicode', Helvetica, Arial, sans-serif; font-size: 0.9em; overflow-x: hidden; overflow-y: auto; margin: 0px !important; padding: 5px 20px 26px !important; background-color: rgb(255, 255, 255);font-family: 'Hiragino Sans GB', 'Microsoft YaHei', STHeiti, SimSun, 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', 'Segoe UI', AppleSDGothicNeo-Medium, 'Malgun Gothic', Verdana, Tahoma, sans-serif; padding: 20px;padding: 20px; color: rgb(34, 34, 34); font-size: 15px; font-family: 'Roboto Condensed', Tauri, 'Hiragino Sans GB', 'Microsoft YaHei', STHeiti, SimSun, 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', 'Segoe UI', AppleSDGothicNeo-Medium, 'Malgun Gothic', Verdana, Tahoma, sans-serif; line-height: 1.6; -webkit-font-smoothing: antialiased; background: rgb(255, 255, 255);&quot;&gt;&lt;h1 id=&quot;fixed-point-in-c&quot; style=&quot;clear: both;font-size: 2.2em; font-weight: bold; margin: 1.5em 0px 1em;margin-top: 0px;&quot;&gt;fixed-point in C&lt;/h1&gt;&lt;p style=&quot;margin-top: 0px;margin: 1em 0px; word-wrap: break-word;&quot;&gt;&lt;strong&gt;original material: &lt;a href=&quot;http://www.artist-embedded.org/docs/Events/2009/EmbeddedControl/SLIDES/FixPoint.pdf&quot; style=&quot;text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);&quot;&gt;artist-embedded.org/EmbeddedControl Slides&lt;/a&gt;&lt;/strong&gt;&lt;br style=&quot;clear: both;&quot;&gt;&lt;strong&gt;reference 1: &lt;a href=&quot;http://www-inst.eecs.berkeley.edu/~cs61c/sp06/handout/fixedpt.html&quot; style=&quot;text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);&quot;&gt;fixedpt.html&lt;/a&gt;&lt;/strong&gt;&lt;br style=&quot;clear: both;&quot;&gt;&lt;strong&gt;reference 2: &lt;a href=&quot;https://en.wikipedia.org/wiki/Q_(number_format&quot; style=&quot;text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);&quot;&gt;Q_format&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&lt;h2 id=&quot;1-fixed-point-representation&quot; style=&quot;clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230);&quot;&gt;1. Fixed-point Representation&lt;/h2&gt;&lt;ul&gt;
&lt;li style=&quot;display: list-item; line-height: 1.4em;&quot;&gt;&lt;em&gt;x&lt;/em&gt;: real number&lt;/li&gt;
&lt;li style=&quot;display: list-item; line-height: 1.4em;&quot;&gt;&lt;em&gt;X&lt;/em&gt;: fixed-point number&lt;/li&gt;
&lt;li style=&quot;display: list-item; line-height: 1.4em;&quot;&gt;&lt;em&gt;N&lt;/em&gt;: wordlength&lt;/li&gt;
&lt;li style=&quot;display: list-item; line-height: 1.4em;&quot;&gt;&lt;em&gt;m&lt;/em&gt;: integer (excluding sign bit)&lt;/li&gt;
&lt;li style=&quot;display: list-item; line-height: 1.4em;&quot;&gt;&lt;em&gt;f&lt;/em&gt;: number of fraction bit&lt;/li&gt;
&lt;li style=&quot;display: list-item; line-height: 1.4em;&quot;&gt;“Q-format” : &lt;em&gt;Qm.n&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;pre style=&quot;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;&quot;&gt;&lt;code data-origin=&quot;&lt;pre&gt;&lt;code&gt;0/1101/011
sign bit/4bit integer/3bit fraction
&lt;/code&gt;&lt;/pre&gt;&quot; style=&quot;border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;&quot;&gt;0/1101/011
sign bit/4bit integer/3bit fraction
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;2-conversion-to-and-from-fixed-point&quot; style=&quot;clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230);&quot;&gt;2. Conversion to and from fixed-point&lt;/h2&gt;&lt;ul&gt;
&lt;li style=&quot;display: list-item; line-height: 1.4em;&quot;&gt;&lt;p style=&quot;margin: 1em 0px; word-wrap: break-word;&quot;&gt;real to fixed &lt;/p&gt;
&lt;ul&gt;
&lt;li style=&quot;display: list-item; line-height: 1.4em;&quot;&gt;Multiply the floating point number by 2^f&lt;/li&gt;
&lt;li style=&quot;display: list-item; line-height: 1.4em;&quot;&gt;Round to the nearest integer&lt;p style=&quot;margin: 1em 0px; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;MathJax_Preview&quot; style=&quot;color: rgb(136, 136, 136);&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;MathJax_Display&quot; role=&quot;textbox&quot; aria-readonly=&quot;true&quot; style=&quot;text-align: center;text-align: center; margin: 1em 0em; position: relative; text-indent: 0px; max-width: none; max-height: none; min-width: 0px; min-height: 0px; width: 100%; display: block !important;&quot;&gt;&lt;span class=&quot;MathJax&quot; id=&quot;MathJax-Element-243-Frame&quot; style=&quot;display: inline; font-style: normal; font-weight: normal; line-height: normal; font-size: 100%; text-indent: 0px; text-align: left; text-transform: none; letter-spacing: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px;&quot;&gt;&lt;nobr style=&quot;border: 0px; padding: 0px; margin: 0px; max-width: 5000em; max-height: 5000em; min-width: 0px; min-height: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;white-space: nowrap !important;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;math&quot; id=&quot;MathJax-Span-4251&quot; style=&quot;width: 9.417em; display: inline-block;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;display: inline-block; position: relative; width: 7.705em; height: 0px; font-size: 122%;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;position: absolute; clip: rect(1.602em 1000em 3.092em -0.466em); top: -2.678em; left: 0em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mrow&quot; id=&quot;MathJax-Span-4252&quot; style=&quot;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mi&quot; id=&quot;MathJax-Span-4253&quot; style=&quot;font-family: MathJax_Math; font-style: italic;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;X&lt;span style=&quot;display: inline-block; overflow: hidden; height: 1px; width: 0.024em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mo&quot; id=&quot;MathJax-Span-4254&quot; style=&quot;font-family: MathJax_Main; padding-left: 0.278em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot; id=&quot;MathJax-Span-4255&quot; style=&quot;font-family: MathJax_Math; font-style: italic; padding-left: 0.278em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;mi&quot; id=&quot;MathJax-Span-4256&quot; style=&quot;font-family: MathJax_Math; font-style: italic;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;mi&quot; id=&quot;MathJax-Span-4257&quot; style=&quot;font-family: MathJax_Math; font-style: italic;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;u&lt;/span&gt;&lt;span class=&quot;mi&quot; id=&quot;MathJax-Span-4258&quot; style=&quot;font-family: MathJax_Math; font-style: italic;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mi&quot; id=&quot;MathJax-Span-4259&quot; style=&quot;font-family: MathJax_Math; font-style: italic;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;d&lt;span style=&quot;display: inline-block; overflow: hidden; height: 1px; width: 0.003em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mo&quot; id=&quot;MathJax-Span-4260&quot; style=&quot;font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot; id=&quot;MathJax-Span-4261&quot; style=&quot;font-family: MathJax_Math; font-style: italic;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;texatom&quot; id=&quot;MathJax-Span-4262&quot; style=&quot;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mrow&quot; id=&quot;MathJax-Span-4263&quot; style=&quot;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;munderover&quot; id=&quot;MathJax-Span-4264&quot; style=&quot;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;display: inline-block; position: relative; width: 0.546em; height: 0px;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;position: absolute; clip: rect(3.825em 1000em 4.153em -0.492em); top: -3.989em; left: 0.273em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mrow&quot; id=&quot;MathJax-Span-4265&quot; style=&quot;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 3.989em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;position: absolute; clip: rect(1.845em 1000em 2.293em -0.302em); top: -2.265em; left: 0em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mo&quot; id=&quot;MathJax-Span-4266&quot; style=&quot;font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;˙&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 2.678em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;msubsup&quot; id=&quot;MathJax-Span-4267&quot; style=&quot;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;display: inline-block; position: relative; width: 1.004em; height: 0px;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;position: absolute; clip: rect(1.848em 1000em 2.842em -0.442em); top: -2.678em; left: 0em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mn&quot; id=&quot;MathJax-Span-4268&quot; style=&quot;font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 2.678em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;position: absolute; top: -2.708em; left: 0.546em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mi&quot; id=&quot;MathJax-Span-4269&quot; style=&quot;font-size: 70.7%; font-family: MathJax_Math; font-style: italic;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;f&lt;span style=&quot;display: inline-block; overflow: hidden; height: 1px; width: 0.042em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 2.295em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mo&quot; id=&quot;MathJax-Span-4270&quot; style=&quot;font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 2.678em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;border-left-width: 0em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.55em; vertical-align: -0.372em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/nobr&gt;&lt;/span&gt;&lt;/div&gt;&lt;script type=&quot;math/tex; mode=display&quot; id=&quot;MathJax-Element-243&quot;&gt;
X = round(x \dot{} 2^f)&lt;/script&gt;&lt;p style=&quot;margin: 1em 0px; word-wrap: break-word;&quot;&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li style=&quot;display: list-item; line-height: 1.4em;&quot;&gt;&lt;p style=&quot;margin: 1em 0px; word-wrap: break-word;&quot;&gt;fixed to real&lt;/p&gt;
&lt;p style=&quot;margin: 1em 0px; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;MathJax_Preview&quot; style=&quot;color: rgb(136, 136, 136);&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;MathJax_Display&quot; role=&quot;textbox&quot; aria-readonly=&quot;true&quot; style=&quot;text-align: center;text-align: center; margin: 1em 0em; position: relative; text-indent: 0px; max-width: none; max-height: none; min-width: 0px; min-height: 0px; width: 100%; display: block !important;&quot;&gt;&lt;span class=&quot;MathJax&quot; id=&quot;MathJax-Element-244-Frame&quot; style=&quot;display: inline; font-style: normal; font-weight: normal; line-height: normal; font-size: 100%; text-indent: 0px; text-align: left; text-transform: none; letter-spacing: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px;&quot;&gt;&lt;nobr style=&quot;border: 0px; padding: 0px; margin: 0px; max-width: 5000em; max-height: 5000em; min-width: 0px; min-height: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;white-space: nowrap !important;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;math&quot; id=&quot;MathJax-Span-4271&quot; style=&quot;width: 5.95em; display: inline-block;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;display: inline-block; position: relative; width: 4.863em; height: 0px; font-size: 122%;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;position: absolute; clip: rect(1.602em 1000em 2.853em -0.457em); top: -2.678em; left: 0em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mrow&quot; id=&quot;MathJax-Span-4272&quot; style=&quot;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mi&quot; id=&quot;MathJax-Span-4273&quot; style=&quot;font-family: MathJax_Math; font-style: italic;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;mo&quot; id=&quot;MathJax-Span-4274&quot; style=&quot;font-family: MathJax_Main; padding-left: 0.278em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot; id=&quot;MathJax-Span-4275&quot; style=&quot;font-family: MathJax_Math; font-style: italic; padding-left: 0.278em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;X&lt;span style=&quot;display: inline-block; overflow: hidden; height: 1px; width: 0.024em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;texatom&quot; id=&quot;MathJax-Span-4276&quot; style=&quot;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mrow&quot; id=&quot;MathJax-Span-4277&quot; style=&quot;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;munderover&quot; id=&quot;MathJax-Span-4278&quot; style=&quot;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;display: inline-block; position: relative; width: 0.546em; height: 0px;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;position: absolute; clip: rect(3.825em 1000em 4.153em -0.492em); top: -3.989em; left: 0.273em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mrow&quot; id=&quot;MathJax-Span-4279&quot; style=&quot;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 3.989em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;position: absolute; clip: rect(1.845em 1000em 2.293em -0.302em); top: -2.265em; left: 0em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mo&quot; id=&quot;MathJax-Span-4280&quot; style=&quot;font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;˙&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 2.678em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;msubsup&quot; id=&quot;MathJax-Span-4281&quot; style=&quot;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;display: inline-block; position: relative; width: 1.55em; height: 0px;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;position: absolute; clip: rect(1.848em 1000em 2.842em -0.442em); top: -2.678em; left: 0em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mn&quot; id=&quot;MathJax-Span-4282&quot; style=&quot;font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 2.678em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;position: absolute; top: -2.763em; left: 0.546em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;texatom&quot; id=&quot;MathJax-Span-4283&quot; style=&quot;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mrow&quot; id=&quot;MathJax-Span-4284&quot; style=&quot;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mo&quot; id=&quot;MathJax-Span-4285&quot; style=&quot;font-size: 70.7%; font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;−&lt;/span&gt;&lt;span class=&quot;mi&quot; id=&quot;MathJax-Span-4286&quot; style=&quot;font-size: 70.7%; font-family: MathJax_Math; font-style: italic;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;f&lt;span style=&quot;display: inline-block; overflow: hidden; height: 1px; width: 0.042em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 2.35em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 2.678em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;border-left-width: 0em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.259em; vertical-align: -0.08em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/nobr&gt;&lt;/span&gt;&lt;/div&gt;&lt;script type=&quot;math/tex; mode=display&quot; id=&quot;MathJax-Element-244&quot;&gt;
x = X \dot{} 2^{-f}&lt;/script&gt;&lt;p style=&quot;margin: 1em 0px; word-wrap: break-word;&quot;&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;p style=&quot;margin: 1em 0px; word-wrap: break-word;&quot;&gt;example) 13.4 to Q4.3 format&lt;/p&gt;&lt;p style=&quot;margin: 1em 0px; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;MathJax_Preview&quot; style=&quot;color: rgb(136, 136, 136);&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div role=&quot;textbox&quot; aria-readonly=&quot;true&quot; style=&quot;text-align: center;text-align: center; margin: 1em 0em; position: relative; text-indent: 0px; max-width: none; max-height: none; min-width: 0px; min-height: 0px; width: 100%; display: block !important;&quot;&gt;&lt;span class=&quot;MathJax&quot; id=&quot;MathJax-Element-229-Frame&quot; style=&quot;display: inline; font-style: normal; font-weight: normal; line-height: normal; font-size: 100%; text-indent: 0px; text-align: left; text-transform: none; letter-spacing: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px;&quot;&gt;&lt;nobr style=&quot;border: 0px; padding: 0px; margin: 0px; max-width: 5000em; max-height: 5000em; min-width: 0px; min-height: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;white-space: nowrap !important;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;math&quot; id=&quot;MathJax-Span-3991&quot; style=&quot;width: 22.083em; display: inline-block;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;display: inline-block; position: relative; width: 18.087em; height: 0px; font-size: 122%;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;position: absolute; clip: rect(1.631em 1000em 3.092em -0.466em); top: -2.678em; left: 0em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mrow&quot; id=&quot;MathJax-Span-3992&quot; style=&quot;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mi&quot; id=&quot;MathJax-Span-3993&quot; style=&quot;font-family: MathJax_Math; font-style: italic;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;X&lt;span style=&quot;display: inline-block; overflow: hidden; height: 1px; width: 0.024em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mo&quot; id=&quot;MathJax-Span-3994&quot; style=&quot;font-family: MathJax_Main; padding-left: 0.278em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot; id=&quot;MathJax-Span-3995&quot; style=&quot;font-family: MathJax_Math; font-style: italic; padding-left: 0.278em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;mi&quot; id=&quot;MathJax-Span-3996&quot; style=&quot;font-family: MathJax_Math; font-style: italic;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;mi&quot; id=&quot;MathJax-Span-3997&quot; style=&quot;font-family: MathJax_Math; font-style: italic;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;u&lt;/span&gt;&lt;span class=&quot;mi&quot; id=&quot;MathJax-Span-3998&quot; style=&quot;font-family: MathJax_Math; font-style: italic;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mi&quot; id=&quot;MathJax-Span-3999&quot; style=&quot;font-family: MathJax_Math; font-style: italic;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;d&lt;span style=&quot;display: inline-block; overflow: hidden; height: 1px; width: 0.003em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mo&quot; id=&quot;MathJax-Span-4000&quot; style=&quot;font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mn&quot; id=&quot;MathJax-Span-4001&quot; style=&quot;font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;13.4&lt;/span&gt;&lt;span class=&quot;texatom&quot; id=&quot;MathJax-Span-4002&quot; style=&quot;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mrow&quot; id=&quot;MathJax-Span-4003&quot; style=&quot;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;munderover&quot; id=&quot;MathJax-Span-4004&quot; style=&quot;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;display: inline-block; position: relative; width: 0.546em; height: 0px;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;position: absolute; clip: rect(3.825em 1000em 4.153em -0.492em); top: -3.989em; left: 0.273em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mrow&quot; id=&quot;MathJax-Span-4005&quot; style=&quot;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 3.989em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;position: absolute; clip: rect(1.845em 1000em 2.293em -0.302em); top: -2.265em; left: 0em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mo&quot; id=&quot;MathJax-Span-4006&quot; style=&quot;font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;˙&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 2.678em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;msubsup&quot; id=&quot;MathJax-Span-4007&quot; style=&quot;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;display: inline-block; position: relative; width: 1.004em; height: 0px;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;position: absolute; clip: rect(1.848em 1000em 2.842em -0.442em); top: -2.678em; left: 0em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mn&quot; id=&quot;MathJax-Span-4008&quot; style=&quot;font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 2.678em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;position: absolute; top: -2.763em; left: 0.546em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mn&quot; id=&quot;MathJax-Span-4009&quot; style=&quot;font-size: 70.7%; font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 2.35em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mo&quot; id=&quot;MathJax-Span-4010&quot; style=&quot;font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mo&quot; id=&quot;MathJax-Span-4011&quot; style=&quot;font-family: MathJax_Main; padding-left: 0.278em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mn&quot; id=&quot;MathJax-Span-4012&quot; style=&quot;font-family: MathJax_Main; padding-left: 0.278em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;107&lt;/span&gt;&lt;span class=&quot;mo&quot; id=&quot;MathJax-Span-4013&quot; style=&quot;font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mo&quot; id=&quot;MathJax-Span-4014&quot; style=&quot;font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;msubsup&quot; id=&quot;MathJax-Span-4015&quot; style=&quot;padding-left: 0.278em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;display: inline-block; position: relative; width: 4.501em; height: 0px;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;position: absolute; clip: rect(1.848em 1000em 2.864em -0.453em); top: -2.678em; left: 0em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mn&quot; id=&quot;MathJax-Span-4016&quot; style=&quot;font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;01101011&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 2.678em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;position: absolute; top: -2.2em; left: 4.044em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mn&quot; id=&quot;MathJax-Span-4017&quot; style=&quot;font-size: 70.7%; font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 2.35em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mo&quot; id=&quot;MathJax-Span-4018&quot; style=&quot;font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 2.678em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;border-left-width: 0em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.516em; vertical-align: -0.372em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/nobr&gt;&lt;/span&gt;&lt;/div&gt;&lt;script type=&quot;math/tex; mode=display&quot; id=&quot;MathJax-Element-229&quot;&gt;
X = round(13.4 \dot{} 2^3) = 107 (=01101011_2)&lt;/script&gt;&lt;p style=&quot;margin: 1em 0px; word-wrap: break-word;&quot;&gt;&lt;/p&gt;&lt;h2 id=&quot;3-range-of-fixed-point-representation&quot; style=&quot;clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230);&quot;&gt;3. Range of fixed-point representation&lt;/h2&gt;&lt;ul&gt;
&lt;li style=&quot;display: list-item; line-height: 1.4em;&quot;&gt;&lt;p style=&quot;margin: 1em 0px; word-wrap: break-word;&quot;&gt;negative number: 2’s complement&lt;/p&gt;
&lt;ul&gt;
&lt;li style=&quot;display: list-item; line-height: 1.4em;&quot;&gt;N=8, 2^(-8) ~ 2^(8-1)&lt;table style=&quot;padding: 0px; border-collapse: collapse; border-spacing: 0px; margin-bottom: 16px;background-color: rgb(250, 250, 250);&quot;&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&quot;border: 1px solid rgb(204, 204, 204); margin: 0px; padding: 6px 13px;font-weight: bold;border: 1px solid rgb(230, 230, 230);&quot;&gt;binary representation&lt;/th&gt;
&lt;th style=&quot;border: 1px solid rgb(204, 204, 204); margin: 0px; padding: 6px 13px;font-weight: bold;border: 1px solid rgb(230, 230, 230);&quot;&gt;decimal&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;border: 1px solid rgb(204, 204, 204); margin: 0px; padding: 6px 13px;border: 1px solid rgb(230, 230, 230);&quot;&gt;00000000&lt;/td&gt;
&lt;td style=&quot;border: 1px solid rgb(204, 204, 204); margin: 0px; padding: 6px 13px;border: 1px solid rgb(230, 230, 230);&quot;&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style=&quot;background-color: rgb(242, 242, 242);&quot;&gt;
&lt;td style=&quot;border: 1px solid rgb(204, 204, 204); margin: 0px; padding: 6px 13px;border: 1px solid rgb(230, 230, 230);&quot;&gt;00000001&lt;/td&gt;
&lt;td style=&quot;border: 1px solid rgb(204, 204, 204); margin: 0px; padding: 6px 13px;border: 1px solid rgb(230, 230, 230);&quot;&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;border: 1px solid rgb(204, 204, 204); margin: 0px; padding: 6px 13px;border: 1px solid rgb(230, 230, 230);&quot;&gt;00000010&lt;/td&gt;
&lt;td style=&quot;border: 1px solid rgb(204, 204, 204); margin: 0px; padding: 6px 13px;border: 1px solid rgb(230, 230, 230);&quot;&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style=&quot;background-color: rgb(242, 242, 242);&quot;&gt;
&lt;td style=&quot;border: 1px solid rgb(204, 204, 204); margin: 0px; padding: 6px 13px;border: 1px solid rgb(230, 230, 230);&quot;&gt;…&lt;/td&gt;
&lt;td style=&quot;border: 1px solid rgb(204, 204, 204); margin: 0px; padding: 6px 13px;border: 1px solid rgb(230, 230, 230);&quot;&gt;…&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;border: 1px solid rgb(204, 204, 204); margin: 0px; padding: 6px 13px;border: 1px solid rgb(230, 230, 230);&quot;&gt;01111111&lt;/td&gt;
&lt;td style=&quot;border: 1px solid rgb(204, 204, 204); margin: 0px; padding: 6px 13px;border: 1px solid rgb(230, 230, 230);&quot;&gt;127&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style=&quot;background-color: rgb(242, 242, 242);&quot;&gt;
&lt;td style=&quot;border: 1px solid rgb(204, 204, 204); margin: 0px; padding: 6px 13px;border: 1px solid rgb(230, 230, 230);&quot;&gt;10000000&lt;/td&gt;
&lt;td style=&quot;border: 1px solid rgb(204, 204, 204); margin: 0px; padding: 6px 13px;border: 1px solid rgb(230, 230, 230);&quot;&gt;-128&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;border: 1px solid rgb(204, 204, 204); margin: 0px; padding: 6px 13px;border: 1px solid rgb(230, 230, 230);&quot;&gt;10000001&lt;/td&gt;
&lt;td style=&quot;border: 1px solid rgb(204, 204, 204); margin: 0px; padding: 6px 13px;border: 1px solid rgb(230, 230, 230);&quot;&gt;-127&lt;/td&gt;
&lt;/tr&gt;
&lt;tr style=&quot;background-color: rgb(242, 242, 242);&quot;&gt;
&lt;td style=&quot;border: 1px solid rgb(204, 204, 204); margin: 0px; padding: 6px 13px;border: 1px solid rgb(230, 230, 230);&quot;&gt;…&lt;/td&gt;
&lt;td style=&quot;border: 1px solid rgb(204, 204, 204); margin: 0px; padding: 6px 13px;border: 1px solid rgb(230, 230, 230);&quot;&gt;…&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;border: 1px solid rgb(204, 204, 204); margin: 0px; padding: 6px 13px;border: 1px solid rgb(230, 230, 230);&quot;&gt;11111111&lt;/td&gt;
&lt;td style=&quot;border: 1px solid rgb(204, 204, 204); margin: 0px; padding: 6px 13px;border: 1px solid rgb(230, 230, 230);&quot;&gt;-1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li style=&quot;display: list-item; line-height: 1.4em;&quot;&gt;&lt;p style=&quot;margin: 1em 0px; word-wrap: break-word;&quot;&gt;range of Qm.f &lt;a href=&quot;https://courses.cs.washington.edu/courses/cse467/08au/pdfs/lectures/11-FixedPointArithmetic.pdf&quot; style=&quot;text-decoration: none; vertical-align: baseline;color: rgb(50, 105, 160);&quot;&gt;[ref]&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 1em 0px; word-wrap: break-word;&quot;&gt;&lt;span class=&quot;MathJax_Preview&quot; style=&quot;color: rgb(136, 136, 136);&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;MathJax_Display&quot; role=&quot;textbox&quot; aria-readonly=&quot;true&quot; style=&quot;text-align: center;text-align: center; margin: 1em 0em; position: relative; text-indent: 0px; max-width: none; max-height: none; min-width: 0px; min-height: 0px; width: 100%; display: block !important;&quot;&gt;&lt;span class=&quot;MathJax&quot; id=&quot;MathJax-Element-251-Frame&quot; style=&quot;display: inline; font-style: normal; font-weight: normal; line-height: normal; font-size: 100%; text-indent: 0px; text-align: left; text-transform: none; letter-spacing: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px;&quot;&gt;&lt;nobr style=&quot;border: 0px; padding: 0px; margin: 0px; max-width: 5000em; max-height: 5000em; min-width: 0px; min-height: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;white-space: nowrap !important;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;math&quot; id=&quot;MathJax-Span-4383&quot; style=&quot;width: 8.017em; display: inline-block;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;display: inline-block; position: relative; width: 6.557em; height: 0px; font-size: 122%;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;position: absolute; clip: rect(1.602em 1000em 3.092em -0.374em); top: -2.678em; left: 0em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mrow&quot; id=&quot;MathJax-Span-4384&quot; style=&quot;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mo&quot; id=&quot;MathJax-Span-4385&quot; style=&quot;font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mo&quot; id=&quot;MathJax-Span-4386&quot; style=&quot;font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;−&lt;/span&gt;&lt;span class=&quot;msubsup&quot; id=&quot;MathJax-Span-4387&quot; style=&quot;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;display: inline-block; position: relative; width: 1.277em; height: 0px;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;position: absolute; clip: rect(1.848em 1000em 2.842em -0.442em); top: -2.678em; left: 0em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mn&quot; id=&quot;MathJax-Span-4388&quot; style=&quot;font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 2.678em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;position: absolute; top: -2.708em; left: 0.546em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mi&quot; id=&quot;MathJax-Span-4389&quot; style=&quot;font-size: 70.7%; font-family: MathJax_Math; font-style: italic;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;m&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 2.295em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mo&quot; id=&quot;MathJax-Span-4390&quot; style=&quot;font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;msubsup&quot; id=&quot;MathJax-Span-4391&quot; style=&quot;padding-left: 0.167em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;display: inline-block; position: relative; width: 1.277em; height: 0px;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;position: absolute; clip: rect(1.848em 1000em 2.842em -0.442em); top: -2.678em; left: 0em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mn&quot; id=&quot;MathJax-Span-4392&quot; style=&quot;font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 2.678em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;position: absolute; top: -2.708em; left: 0.546em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mi&quot; id=&quot;MathJax-Span-4393&quot; style=&quot;font-size: 70.7%; font-family: MathJax_Math; font-style: italic;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;m&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 2.295em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mo&quot; id=&quot;MathJax-Span-4394&quot; style=&quot;font-family: MathJax_Main; padding-left: 0.222em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;−&lt;/span&gt;&lt;span class=&quot;msubsup&quot; id=&quot;MathJax-Span-4395&quot; style=&quot;padding-left: 0.222em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;display: inline-block; position: relative; width: 1.004em; height: 0px;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span style=&quot;position: absolute; clip: rect(1.848em 1000em 2.842em -0.442em); top: -2.678em; left: 0em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mn&quot; id=&quot;MathJax-Span-4396&quot; style=&quot;font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 2.678em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;position: absolute; top: -2.708em; left: 0.546em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;span class=&quot;mi&quot; id=&quot;MathJax-Span-4397&quot; style=&quot;font-size: 70.7%; font-family: MathJax_Math; font-style: italic;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;f&lt;span style=&quot;display: inline-block; overflow: hidden; height: 1px; width: 0.042em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 2.295em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mo&quot; id=&quot;MathJax-Span-4398&quot; style=&quot;font-family: MathJax_Main;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;display: inline-block; width: 0px; height: 2.678em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;border-left-width: 0em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.55em; vertical-align: -0.372em;display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; text-decoration: none;-webkit-transition: none; transition: none;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/nobr&gt;&lt;/span&gt;&lt;/div&gt;&lt;script type=&quot;math/tex; mode=display&quot; id=&quot;MathJax-Element-251&quot;&gt;
[-2^m , 2^m - 2^f]&lt;/script&gt;&lt;p style=&quot;margin: 1em 0px; word-wrap: break-word;&quot;&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;h2 id=&quot;4-arithmetic-operations-of-fixed-point&quot; style=&quot;clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(230, 230, 230);&quot;&gt;4. Arithmetic operations of fixed-point&lt;/h2&gt;&lt;ul&gt;
&lt;li style=&quot;display: list-item; line-height: 1.4em;&quot;&gt;Satuation check&lt;/li&gt;
&lt;/ul&gt;&lt;pre style=&quot;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: rgb(101, 123, 131); background: rgb(253, 246, 227);&quot;&gt;&lt;code class=&quot;cpp&quot; data-origin=&quot;&lt;pre&gt;&lt;code class=&amp;quot;cpp&amp;quot;&gt;int16_t sat16(int32_t x)
{
    if (x &amp;amp;gt; 0x7FFF) return 0x7FFF;
    else if (x &amp;amp;lt; 0x8000) return 0x8000;
    else return (int16_t)x;
}
&lt;/code&gt;&lt;/pre&gt;&quot; style=&quot;border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;&quot;&gt;&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int16_t&lt;/span&gt; &lt;span class=&quot;hljs-title&quot; style=&quot;color: rgb(38, 139, 210);&quot;&gt;sat16&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int32_t&lt;/span&gt; x)&lt;/span&gt;
&lt;/span&gt;{
    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt; (x &amp;gt; &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;0x7FFF&lt;/span&gt;) &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;0x7FFF&lt;/span&gt;;
    &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hljs-title&quot; style=&quot;color: rgb(38, 139, 210);&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hljs-params&quot;&gt;(x &amp;lt; 0x8000)&lt;/span&gt; return 0x8000&lt;/span&gt;;
    &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hljs-title&quot; style=&quot;color: rgb(38, 139, 210);&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-params&quot;&gt;(&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int16_t&lt;/span&gt;)&lt;/span&gt;x&lt;/span&gt;;
}
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li style=&quot;display: list-item; line-height: 1.4em;&quot;&gt;Addition&lt;/li&gt;
&lt;/ul&gt;&lt;pre style=&quot;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: rgb(101, 123, 131); background: rgb(253, 246, 227);&quot;&gt;&lt;code class=&quot;cpp&quot; data-origin=&quot;&lt;pre&gt;&lt;code class=&amp;quot;cpp&amp;quot;&gt;int16_t q_add_sat(int16_t a, int16_t b)
{
    int16_t result;
    int32_t tmp;

    tmp = (int32_t)a + (int32_t)b;
    if (tmp &amp;amp;gt; 0x7FFF)
        tmp = 0x7FFF;
    if (tmp &amp;amp;lt; -1 * 0x8000)
        tmp = -1 * 0x8000;
    result = (int16_t)tmp;

    return result;
}
&lt;/code&gt;&lt;/pre&gt;&quot; style=&quot;border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;&quot;&gt;&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int16_t&lt;/span&gt; &lt;span class=&quot;hljs-title&quot; style=&quot;color: rgb(38, 139, 210);&quot;&gt;q_add_sat&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int16_t&lt;/span&gt; a, &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int16_t&lt;/span&gt; b)&lt;/span&gt;
&lt;/span&gt;{
    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int16_t&lt;/span&gt; result;
    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int32_t&lt;/span&gt; tmp;

    tmp = (&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int32_t&lt;/span&gt;)a + (&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int32_t&lt;/span&gt;)b;
    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt; (tmp &amp;gt; &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;0x7FFF&lt;/span&gt;)
        tmp = &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;0x7FFF&lt;/span&gt;;
    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt; (tmp &amp;lt; -&lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt; * &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;0x8000&lt;/span&gt;)
        tmp = -&lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;1&lt;/span&gt; * &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;0x8000&lt;/span&gt;;
    result = (&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int16_t&lt;/span&gt;)tmp;

    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;return&lt;/span&gt; result;
}
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li style=&quot;display: list-item; line-height: 1.4em;&quot;&gt;Subtraction&lt;/li&gt;
&lt;/ul&gt;&lt;pre style=&quot;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: rgb(101, 123, 131); background: rgb(253, 246, 227);&quot;&gt;&lt;code class=&quot;cpp&quot; data-origin=&quot;&lt;pre&gt;&lt;code class=&amp;quot;cpp&amp;quot;&gt;int16_t q_sub(int16_t a, int16_t b)
{
    int16_t result;
    result = a - b;
    return result;
}
&lt;/code&gt;&lt;/pre&gt;&quot; style=&quot;border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;&quot;&gt;&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int16_t&lt;/span&gt; &lt;span class=&quot;hljs-title&quot; style=&quot;color: rgb(38, 139, 210);&quot;&gt;q_sub&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int16_t&lt;/span&gt; a, &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int16_t&lt;/span&gt; b)&lt;/span&gt;
&lt;/span&gt;{
    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int16_t&lt;/span&gt; result;
    result = a - b;
    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;return&lt;/span&gt; result;
}
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li style=&quot;display: list-item; line-height: 1.4em;&quot;&gt;Multiplication&lt;/li&gt;
&lt;/ul&gt;&lt;pre style=&quot;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: rgb(101, 123, 131); background: rgb(253, 246, 227);&quot;&gt;&lt;code class=&quot;cpp&quot; data-origin=&quot;&lt;pre&gt;&lt;code class=&amp;quot;cpp&amp;quot;&gt;// precomputed value:
#define K   (1 &amp;amp;lt;&amp;amp;lt; (f - 1))    // f: fraction of fixed-point

int16_t q_mul(int16_t a, int16_t b)
{
    int16_t result;
    int32_t temp;

    temp = (int32_t)a * (int32_t)b; // result type is operand's type
    // Rounding; mid values are rounded up
    temp += K;
    // Correct by dividing by base and saturate result
    result = sat16(temp &amp;amp;gt;&amp;amp;gt; Q);

    return result;
}
&lt;/code&gt;&lt;/pre&gt;&quot; style=&quot;border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;&quot;&gt;&lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;// precomputed value:&lt;/span&gt;
&lt;span class=&quot;hljs-preprocessor&quot; style=&quot;color: rgb(203, 75, 22);&quot;&gt;#&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);color: rgb(203, 75, 22);&quot;&gt;define&lt;/span&gt; K   (1 &amp;lt;&amp;lt; (f - 1))    &lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;// f: fraction of fixed-point&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int16_t&lt;/span&gt; &lt;span class=&quot;hljs-title&quot; style=&quot;color: rgb(38, 139, 210);&quot;&gt;q_mul&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int16_t&lt;/span&gt; a, &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int16_t&lt;/span&gt; b)&lt;/span&gt;
&lt;/span&gt;{
    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int16_t&lt;/span&gt; result;
    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int32_t&lt;/span&gt; temp;

    temp = (&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int32_t&lt;/span&gt;)a * (&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int32_t&lt;/span&gt;)b; &lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;// result type is operand's type&lt;/span&gt;
    &lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;// Rounding; mid values are rounded up&lt;/span&gt;
    temp += K;
    &lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;// Correct by dividing by base and saturate result&lt;/span&gt;
    result = sat16(temp &amp;gt;&amp;gt; Q);

    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;return&lt;/span&gt; result;
}
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li style=&quot;display: list-item; line-height: 1.4em;&quot;&gt;Division&lt;/li&gt;
&lt;/ul&gt;&lt;pre style=&quot;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; color: rgb(101, 123, 131); background: rgb(253, 246, 227);&quot;&gt;&lt;code class=&quot;cpp&quot; data-origin=&quot;&lt;pre&gt;&lt;code class=&amp;quot;cpp&amp;quot;&gt;int16_t q_div(int16_t a, int16_t b)
{
    int16_t result;
    int32_t temp;

    // pre-multiply by the base (Upscale to Q16 so that the result will be in Q8 format)
    temp = (int32_t)a &amp;amp;lt;&amp;amp;lt; Q;
    // Rounding: mid values are rounded up (down for negative values).
    if ((temp &amp;amp;gt;= 0 &amp;amp;amp;&amp;amp;amp; b &amp;amp;gt;= 0) || (temp &amp;amp;lt; 0 &amp;amp;amp;&amp;amp;amp; b &amp;amp;lt; 0))
        temp += b / 2;
    else
        temp -= b / 2;
    result = (int16_t)(temp / b);

    return result;
}
&lt;/code&gt;&lt;/pre&gt;&quot; style=&quot;border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 1em; letter-spacing: -1px; font-weight: bold;&quot;&gt;&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int16_t&lt;/span&gt; &lt;span class=&quot;hljs-title&quot; style=&quot;color: rgb(38, 139, 210);&quot;&gt;q_div&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int16_t&lt;/span&gt; a, &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int16_t&lt;/span&gt; b)&lt;/span&gt;
&lt;/span&gt;{
    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int16_t&lt;/span&gt; result;
    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int32_t&lt;/span&gt; temp;

    &lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;// pre-multiply by the base (Upscale to Q16 so that the result will be in Q8 format)&lt;/span&gt;
    temp = (&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int32_t&lt;/span&gt;)a &amp;lt;&amp;lt; Q;
    &lt;span class=&quot;hljs-comment&quot; style=&quot;color: rgb(147, 161, 161);&quot;&gt;// Rounding: mid values are rounded up (down for negative values).&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;if&lt;/span&gt; ((temp &amp;gt;= &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt; &amp;amp;&amp;amp; b &amp;gt;= &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;) || (temp &amp;lt; &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt; &amp;amp;&amp;amp; b &amp;lt; &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;0&lt;/span&gt;))
        temp += b / &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;2&lt;/span&gt;;
    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;else&lt;/span&gt;
        temp -= b / &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(42, 161, 152);&quot;&gt;2&lt;/span&gt;;
    result = (&lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;int16_t&lt;/span&gt;)(temp / b);

    &lt;span class=&quot;hljs-keyword&quot; style=&quot;color: rgb(133, 153, 0);&quot;&gt;return&lt;/span&gt; result;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
      <category>C and C++</category>
      <author>loekohc</author>
      <guid isPermaLink="true">https://loekohcoder.tistory.com/20</guid>
      <comments>https://loekohcoder.tistory.com/20#entry20comment</comments>
      <pubDate>Tue, 5 Apr 2016 21:03:00 +0900</pubDate>
    </item>
    <item>
      <title>bash script 예제</title>
      <link>https://loekohcoder.tistory.com/19</link>
      <description>&lt;div style=&quot;font-family: 'Lucida Grande', 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Lucida Sans Unicode', Helvetica, Arial, sans-serif; font-size: 0.9em; overflow-x: hidden; overflow-y: auto; margin: 0px !important; padding: 5px 20px 26px !important; background-color: rgb(255, 255, 255);font-family: 'Hiragino Sans GB', 'Microsoft YaHei', STHeiti, SimSun, 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', 'Segoe UI', AppleSDGothicNeo-Medium, 'Malgun Gothic', Verdana, Tahoma, sans-serif; padding: 20px;padding: 20px; color: rgb(115, 115, 115); font-size: 15px; -webkit-font-smoothing: antialiased; background: rgb(255, 255, 255);height: 100%;&quot;&gt;&lt;h2 id=&quot;bash-script를-이용해-실험-여러-번-돌리기.&quot; style=&quot;clear: both;font-size: 1.8em; font-weight: bold; margin: 1.275em 0px 0.85em;margin-top: 0px;color: rgb(64, 64, 64);border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(204, 204, 204); line-height: 1.7em;line-height: 1.1; font-family: D2Coding, Baskerville, 'Goudy Old Style', Palatino, 'Book Antiqua', serif;font-size: 22pt;&quot;&gt;&lt;a name=&quot;bash-script를-이용해-실험-여러-번-돌리기.&quot; href=&quot;#bash-script를-이용해-실험-여러-번-돌리기.&quot; style=&quot;text-decoration: none; vertical-align: baseline;color: rgb(30, 110, 167);text-decoration: none; cursor: pointer; color: rgb(186, 131, 44); font-weight: bold;&quot;&gt;&lt;/a&gt;bash script를 이용해 실험 여러 번 돌리기.&lt;/h2&gt;&lt;p style=&quot;margin-top: 0px;margin: 1em 0px; word-wrap: break-word;margin-bottom: 1em;&quot;&gt;컴퓨터 한테 한꺼번에 많은 일들을 시키기 위해 결국 bash 스크립트도 조금 알아보았다.
대단한 것은 아니고, 인자들을 바꾸어가며 실험을 여러 번 돌리고, 매 번 실행되는 결과 파일을 파라메터에 맞게 네이밍 하는 것.&lt;/p&gt;&lt;p style=&quot;margin: 1em 0px; word-wrap: break-word;margin-bottom: 1em;&quot;&gt;생각보다 bash script로는 많은 것을 할 수도 있었지만, 제약사항도 조금 있었다.
다들 그래서 &lt;code style=&quot;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;&quot;&gt;python&lt;/code&gt; 을 사용하나보다.&lt;/p&gt;&lt;pre style=&quot;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 0.5em;display: block; overflow-x: auto; padding: 0.5em; background: rgb(240, 240, 240);color: black;margin-bottom: 1em;color: rgb(255, 255, 255); padding: 8px 10px; border-top-left-radius: 0.4em; border-top-right-radius: 0.4em; border-bottom-right-radius: 0.4em; border-bottom-left-radius: 0.4em; overflow-x: hidden; background: rgba(0, 0, 0, 0.298039);&quot;&gt;&lt;code class=&quot;cpp&quot; data-origin=&quot;&lt;pre&gt;&lt;code class=&amp;quot;cpp&amp;quot;&gt;#! /bin/bash

for (( i = 1.8 ; i &amp;amp;lt;= 3.0 ; i+=0.2 ))
do
    ./a.out $i 2.3
    f=1.8+$i
    mv a.txt hey_$f.txt
#done
&lt;/code&gt;&lt;/pre&gt;&quot; style=&quot;border: 0px; display: block;font-family: Consolas, Inconsolata, Courier, monospace; font-weight: bold; white-space: pre; margin: 0px;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;font-size: 0.9em;font-size: 10pt;&quot;&gt;&lt;span class=&quot;hljs-preprocessor&quot; style=&quot;color: rgb(136, 0, 0);&quot;&gt;#! /bin/bash&lt;/span&gt;

&lt;span class=&quot;hljs-keyword&quot; style=&quot;font-weight: bold;&quot;&gt;for&lt;/span&gt; (( i = &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(0, 136, 0);&quot;&gt;1.8&lt;/span&gt; ; i &amp;lt;= &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(0, 136, 0);&quot;&gt;3.0&lt;/span&gt; ; i+=&lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(0, 136, 0);&quot;&gt;0.2&lt;/span&gt; ))
&lt;span class=&quot;hljs-keyword&quot; style=&quot;font-weight: bold;&quot;&gt;do&lt;/span&gt;
    ./a.out $i &lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(0, 136, 0);&quot;&gt;2.3&lt;/span&gt;
    f=&lt;span class=&quot;hljs-number&quot; style=&quot;color: rgb(0, 136, 0);&quot;&gt;1.8&lt;/span&gt;+$i
    mv a.txt hey_$f.txt
&lt;span class=&quot;hljs-preprocessor&quot; style=&quot;color: rgb(136, 0, 0);&quot;&gt;#done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p style=&quot;margin: 1em 0px; word-wrap: break-word;margin-bottom: 1em;&quot;&gt;배포할 목적이 아니라 예외처리는 전혀 안되어 있지만, 그리고 실제로 실험에 사용한 코드도 이것이 아니긴 하지만, 무튼 이런 식으로 할 수 있다는 것.
(()) 이 중첩 괄호 사이에 넣으면 C 구문도 넣을 수 있다고…
하지만 실수 연산이 안되기 때문에 뭔가 다른 방법을 사용했던 것 같은데, 
지금 나는 절실히 필요한 것이 아니니 다음 기회로 넘기자.&lt;/p&gt;&lt;p style=&quot;margin: 1em 0px; word-wrap: break-word;margin-bottom: 1em;&quot;&gt;우선 &lt;code style=&quot;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;&quot;&gt;a.out&lt;/code&gt; 이라는 프로그램은 인자가 두 개 들어가는 실행 프로그램이다.
&lt;code style=&quot;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;&quot;&gt;$i&lt;/code&gt; 는 bash script 에서는 변수 i 를 뜻한다. 연산은 안되지만 실행할 때 대입은 되는 신기한 상황.
무튼, 변수를 바꿔가며 조건을 만족할 때까지 실행한다.&lt;/p&gt;&lt;p style=&quot;margin: 1em 0px; word-wrap: break-word;margin-bottom: 1em;&quot;&gt;&lt;code style=&quot;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;&quot;&gt;a.out&lt;/code&gt; 은 실험 결과로 &lt;code style=&quot;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;&quot;&gt;a.txt&lt;/code&gt;를 생성하는데, 실행이 끝날 때마다 &lt;code style=&quot;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;&quot;&gt;a.txt&lt;/code&gt;를 &lt;code style=&quot;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;&quot;&gt;hey_$f.txt&lt;/code&gt;로 이름을 바꾸어준다. &lt;/p&gt;&lt;p style=&quot;margin: 1em 0px; word-wrap: break-word;margin-bottom: 1em;&quot;&gt;주말동안 열심히 서버에다가 일을 시켜 두었으니, 월요일에 출근해서 살펴봐야겠다.&lt;/p&gt;&lt;p style=&quot;margin: 1em 0px; word-wrap: break-word;margin-bottom: 1em;&quot;&gt;윈도우용 &lt;code style=&quot;border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: break-word; border: 1px solid rgb(204, 204, 204); padding: 0px 5px; margin: 0px 2px;&quot;&gt;.bat&lt;/code&gt; 파일도 이런 식으로 스크립트를 만들 수 있는 것 같으니, 서버 말고 연구실 메인 컴퓨터도 실험을 돌리자.&lt;/p&gt;&lt;p style=&quot;margin: 1em 0px; word-wrap: break-word;margin-bottom: 1em;&quot;&gt;Do or do not. There’s no try. 아자.&lt;/p&gt;&lt;/div&gt;</description>
      <category>etc.</category>
      <category>bash script</category>
      <author>loekohc</author>
      <guid isPermaLink="true">https://loekohcoder.tistory.com/19</guid>
      <comments>https://loekohcoder.tistory.com/19#entry19comment</comments>
      <pubDate>Mon, 14 Mar 2016 00:46:24 +0900</pubDate>
    </item>
    <item>
      <title>main function arguments</title>
      <link>https://loekohcoder.tistory.com/18</link>
      <description>&lt;h2 id=&quot;main-argument&quot;&gt;main 함수의 argument&lt;/h2&gt;
&lt;pre&gt;&lt;code class=&quot;cpp&quot;&gt;#include &amp;lt;stdio.h&amp;gt;

int main(int argc, char* argv [])
{
    printf(&amp;quot;num_of_param: %d, program_name: %s&amp;quot;, argc, argv[0]);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href=&quot;http://www.tipssoft.com/bulletin/board.php?bo_table=FAQ&amp;amp;wr_id=791&quot;&gt;참고자료&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;프로그램을 실행할 때 인자를 받아와서 프로그램에서 사용할 수 있다.
&lt;code&gt;scanf&lt;/code&gt;로 받아오는 것으로 짜려고 했더니 bash script 로 여러 번 실행할 수가 없어서 다시 써볼까 싶어 찾아봤는데, 하도 오래 전에 써본 터라 기억이 제대로 나지 않았다.
공부한 김에 메모하는 것으로.&lt;/p&gt;
&lt;p&gt;위의 프로그램을 컴파일하고 아무런 인자도 넣지 않은 채 실행하면 다음과 같은 결과를 볼 수 있다.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;num_of_param: 1, program_name: ./b.out
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;ps. &lt;code&gt;b.out&lt;/code&gt;은 컴파일 후 생성된 실행파일이다.&lt;/p&gt;
&lt;p&gt;이 예제를 통해 메인함수는 기본적으로 프로그램 이름을 하나의 인자로 가진다는 것을 알 수 있다.&lt;/p&gt;
&lt;p&gt;문제는 이렇게 받아오는 인자가 문자열이라는 것.&lt;/p&gt;
&lt;p&gt;가장 단순한 해결방법으로는 묵직한 &lt;code&gt;atoi&lt;/code&gt;함수를 사용하는 방법이다.&lt;/p&gt;
&lt;p&gt;일단 실험이 급하니 이것부터 이용해서 해볼까 싶다.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;

int main(int argc, char *argv[])
{

    printf(&amp;quot;input was %d and %d&amp;quot;, atoi(argv[1]), atoi(argv[2]) );

    return 0;

}
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;위 코드를 컴파일한 후 &lt;code&gt;$&amp;gt;a.out 1 2&lt;/code&gt; 이렇게 실행하면 다음과 같은 결과를 볼 수 있다.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;input was 1 and 2
&lt;/code&gt;&lt;/pre&gt;</description>
      <category>C and C++</category>
      <author>loekohc</author>
      <guid isPermaLink="true">https://loekohcoder.tistory.com/18</guid>
      <comments>https://loekohcoder.tistory.com/18#entry18comment</comments>
      <pubDate>Fri, 11 Mar 2016 22:08:30 +0900</pubDate>
    </item>
  </channel>
</rss>