Skip to content

Instantly share code, notes, and snippets.

@sugamasao
Created August 20, 2011 03:59
Show Gist options
  • Save sugamasao/1158633 to your computer and use it in GitHub Desktop.
Save sugamasao/1158633 to your computer and use it in GitHub Desktop.
整数値を16進数のコロン区切りに
:035 > 100000.to_s(16).reverse.scan(/.{1,4}/).join(':').reverse
=> "1:86a0"
:036 > 102400.to_s(16).reverse.scan(/.{1,4}/).join(':').reverse
=> "1:9000"
:037 > 102400.to_s(16)
=> "19000"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment