- 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
推薦閱讀
- Reporting with Visual Studio and Crystal Reports
- Cocos2D-X權威指南(第2版)
- Mastering QGIS
- 精通Linux(第2版)
- Jenkins Continuous Integration Cookbook(Second Edition)
- Learning Probabilistic Graphical Models in R
- Extending Puppet(Second Edition)
- Java編程的邏輯
- 速學Python:程序設計從入門到進階
- Advanced Express Web Application Development
- Mastering Web Application Development with AngularJS
- Python數據可視化之美:專業圖表繪制指南(全彩)
- Apache Solr for Indexing Data
- 軟件再工程:優化現有軟件系統的方法與最佳實踐
- Django 2.0 入門與實踐