Skip to content

Instantly share code, notes, and snippets.

@kwmt
Last active October 15, 2019 05:22
Show Gist options
  • Save kwmt/edf4dd2d563f667f5f59a00feb0cb058 to your computer and use it in GitHub Desktop.
Save kwmt/edf4dd2d563f667f5f59a00feb0cb058 to your computer and use it in GitHub Desktop.
val num = 'a'.toValue()
println(num)
// Output
// 42
private fun Char.toValue() : Int{
// 仕様: https://www.icao.int/publications/Documents/9303_p3_cons_en.pdf の 20ページの最後から21ページの最初
val num = this.toInt() - '0'.toInt()
if(num < 10) {
return num
}
val ascii = this.toInt()
return ascii - 55
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment