Skip to content

Instantly share code, notes, and snippets.

@wang-zhijun
Created April 6, 2016 02:29
Show Gist options
  • Select an option

  • Save wang-zhijun/43c3636983ab70cac1b706bc26b9ae35 to your computer and use it in GitHub Desktop.

Select an option

Save wang-zhijun/43c3636983ab70cac1b706bc26b9ae35 to your computer and use it in GitHub Desktop.
Erlangのioモジュールのformat

Erlangのioモジュールの出力フォーマットの一部をチェックしてみる

数字97を2桁で出力

54> io:fwrite("|~2b|~n", [97]).
|97|
ok

数字97を3桁で出力

53> io:fwrite("|~3b|~n", [97]).
| 97|
ok

数字97を2進数で出力

52> io:fwrite("|~.2b|~n", [97]).
|1100001|
ok

数字97を2進数で出力して、10桁のスペースを使う

50> io:fwrite("|~10.2b|~n", [97]).
|   1100001|
ok

数字97をデフォルトの10進数で出力して、足りない部分は0で補う

55> io:fwrite("|~5..0b|~n", [97]).
|00097|
ok
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment