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

  • 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
主站蜘蛛池模板: 迁安市| 尚义县| 牡丹江市| 三台县| 金沙县| 福鼎市| 昌宁县| 萨嘎县| 滦南县| 库车县| 商都县| 兴安盟| 彩票| 伽师县| 凯里市| 双鸭山市| 长垣县| 团风县| 察哈| 江安县| 沐川县| 淮阳县| 上虞市| 门头沟区| 留坝县| 汝南县| 晋州市| 松原市| 澄江县| 松原市| 百色市| 任丘市| 宁明县| 崇阳县| 延边| 定远县| 武城县| 吉木萨尔县| 资兴市| 嘉禾县| 鲁山县|