官术网_书友最值得收藏!

  • Mastering Elixir
  • André Albuquerque Daniel Caixinha
  • 111字
  • 2021-08-05 10:42:44

Integers

This type contains, as you would expect, numbers that can be written without a fractional component. The size of integers adjusts dynamically according to its magnitude—you don't have to worry about this: an integer will simply occupy more words in memory as it grows. Here's some basic arithmetic with integers:

iex> 25 + 8
33

To improve the readability of the code, you can also use underscores in between the digits of an integer, as shown here:

iex> 1_000_000 - 500_000
500000

Besides decimal, Elixir also supports integers written in binary, octal, and hexadecimal (using 0b, 0o, and 0x, respectively):

iex> 0b10001
17
iex> 0o21
17
iex> 0x11
17
主站蜘蛛池模板: 全州县| 古交市| 安仁县| 商水县| 额济纳旗| 富裕县| 白沙| 黄龙县| 永兴县| 大关县| 铁岭市| 永胜县| 平泉县| 泉州市| 江永县| 重庆市| 娄烦县| 拜泉县| 屯留县| 应城市| 威信县| 札达县| 玉门市| 通辽市| 如皋市| 巴林左旗| 平山县| 普兰店市| 铜山县| 张家港市| 北票市| 紫阳县| 雷州市| 云南省| 柘荣县| 郓城县| 喀喇沁旗| 大竹县| 石门县| 鹤壁市| 麻江县|