How do you write a binary literal in ruby?

后端 未结 4 703
忘掉有多难
忘掉有多难 2021-02-18 13:33

Most languages (Ruby included) allow number literals to be written in at least three bases: decimal, octal and hexadecimal. Numbers in decimal base is the usual thing and are wr

4条回答
  •  醉梦人生
    2021-02-18 14:24

    and you can do:

    >> easy_to_read_binary = 0b1110_0000_0000_0000
    => 57344
    >> easy_to_read_binary.to_s(10)
    => "57344"
    

提交回复
热议问题