4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Perl 6Advent Calendar 2015

Day 7

Perl6 でN進法に変換するワンライナー

Posted at

こんばんは :whale2:

Perl 6 Advent Calendar 2015の7日目ぐらいです。

新人さんに2進法とか16進法のクイズを出したのですが、その答え的なワンライナーです。

16進法のFFFFって10進でいくつでしょう

$ perl6 -e 'say :16("FFFF")'
65535

2進法の1010って10進でいくつでしょう

$ perl6 -e 'say :2("1010")'
10

10進法の1000って16進でいくつでしょう

$ perl6 -e 'say 1000.fmt("%x");'
3e8

10進法の8って2進でいくつでしょう

$ perl6 -e 'say 8.fmt("%b");'
1000

おわりです。

参考と注釈

4
4
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?