Entries from 2019-07-01 to 1 month

Pythonで浮動小数点数をビットパターンに変換する方法

64bit浮動小数点数(1.0の例) >>> import struct >>> hex(struct.unpack('<Q', struct.pack('<d', 1.0))[0]) '0x3ff0000000000000' 32bit浮動小数点数(1.0の例) >>> import struct >>> hex(struct.unpack('<I', struct.pack('<f', 1.0))[0]) '0x3f800000' 16bit浮動小数点数(1.0の例) Python3.6以上で動く >>> import struct >>> hex(struct.unpack('</i',></q',>

Vim練習1

正規表現で検索した文字列を置換する方法 ファイル全体に対して、一括で置換を行うコマンド :%s/\v<正規表現>/<置換後文字列/g ドットコマンドを使って置換を行う方法 まず、以下で検索する /\v<正規表現> 次に1つ目の検索対象を置換する cgn<置換後文字列>…

自分用メモ ARM64クロスコンパイルとx86_64での実行

参考サイト qiita.com 環境はx86_64, Ubuntu 18.04.2 LTS。 まず、qemuとg++-aarch64-linux-gnuを以下のようにインストール。 $ sudo apt-get install qemu $ sudo apt-get install g++-aarch64-linux-gnu helloworld.c #include <stdio.h> int main() { printf("hell</stdio.h>…