Jack Ho

@quantabase13

Joined on May 24, 2020

  • contributed by < quantabase13 > 程式運作原理 NEXT_POWER_OF_2(s) 先從巨集 v 的實作看起: #define v(t, s, name, ...) \ union { \ STRUCT_BODY(t); \ struct { \
     Like  Bookmark
  • contributed by < quantabase13 > 程式運作原理 測驗 1 int asr_i(signed int m, unsigned int n) { const int logical = (((int) -1) >>1/*OP1*/) > 0; unsigned int fixu = -(logical & ( m < 0/*OP2*/)); int fix = *(int *) &fixu; return (m >> n) | (fix ^ (fix >> n));
     Like  Bookmark
  • contributed by < quantabase13 >
     Like  Bookmark
  • contributed by < quantabase13 >
     Like  Bookmark
  • contributed by < quantabase13 > 程式運作原理 測驗一: 程式碼運作原理如下: $$ \begin{aligned}{{\dfrac{a}{b}}-{\dfrac{a}{b+1}}}&={\dfrac{a}{b\cdot(b+1)}} \&={\dfrac{\dfrac{a}{b+1}}{b}} \end{aligned}
     Like  Bookmark
  • contributed by < quantabase13 > 修正 Raycaster( floating point part ) overflowing problem 在 void RayCasterFloat::Trace 中的程式碼: *screenY = INV_FACTOR / distance;
     Like  Bookmark
  • contributed by < quantabase13 > 程式運作原理 測驗一 int hammingDistance(int x, int y) { return __builtin_popcount(x ^/*OP*/ y); } 根據題目提及,兩個數的 Hamming distance 其實就是其二進位表示中,相應位置數值不同的 bit 個數。 以 1 與 4 為例:
     Like  Bookmark
  • contributed by < quantabase13 > CPY 和 REF 實作的效能差異分析 在 dict 目錄下完成編譯後,執行 $ ./test_common --bench CPY 可以得到 bench_ref.txt 文件。 為了確認這份文件中的資料代表的意思,觀察了test_common.c 中的程式碼,其中一部份如下:
     Like  Bookmark
  • contributed by < quantabase13 > :memo: Table of Contents [TOC] 程式運作原理 測驗 1 #include <stdbool.h> #include <stddef.h> #include <stdint.h>
     Like  Bookmark
  • contributed by < quantabase13 > 說明 作業說明 作業要求 實作 queue,此 queue 能從 head 處插入 element。 需要實現的函式:
     Like  Bookmark