当前位置: 首页 > 编程笔记 >

Elixir号码

楚嘉纳
2023-03-14
本文向大家介绍Elixir号码,包括了Elixir号码的使用技巧和注意事项,需要的朋友参考一下

示例

Elixir带有整数浮点数。一个整数文字可以写成十进制,二进制,八进制和十六进制格式。

iex> x = 291
291

iex> x = 0b100100011
291

iex> x = 0o443
291

iex> x = 0x123
291

由于Elixir使用bignum算法,因此整数范围仅受系统上可用内存的限制

浮点数是双精度的,并且遵循IEEE-754规范。

iex> x = 6.8
6.8

iex> x = 1.23e-11
1.23e-11

请注意,Elixir还支持浮点数的指数形式。

iex> 1 + 1
2

iex> 1.0 + 1.0
2.0

首先,我们将两个整数相加,结果是一个整数。后来我们添加了两个浮点数,结果是一个浮点数。

除以Elixir总是返回一个浮点数:

iex> 10 / 2
5.0

以相同的方式,如果您将一个整数与一个浮点数相加,相减或相乘,结果将为浮点数:

iex> 40.0 + 2
42.0

iex> 10 - 5.0
5.0

iex> 3 * 3.0
9.0

对于整数除法,可以使用以下div/2函数:

iex> div(10, 2)
5
           

 类似资料:
  • 本文向大家介绍Elixir管道运算符和括号,包括了Elixir管道运算符和括号的使用技巧和注意事项,需要的朋友参考一下 示例 需要括号以避免模棱两可: 应写为:            

  • Elixir是基于python界有名的ORM库SQLAlchemy做的封装。而且是轻量级的封装,它提供了更简单的方式来创建Python类并直接映射到关系数据库表(即通常所说的Active Record设计模式),类似于Django中的ORM。 示例: class Person(Entity): name = Field(String(128)) addresses = OneToMan

  • Table of Contents Elixir plugin IDEs Features Project From Existing Sources Import project from external model Create project from existing sources New Project Structure Project Settings Module Settin

  • �� Timber - Great Elixir Logging Made Easy Timber.io is a hosted service for aggregating logs across your entire stack -any language,any platform,any data source. Unlike traditional logging tools, Tim

  • This repository is the stable base upon which we build our Elixir projects at Mirego. We want to share it with the world so you can build awesome Elixir applications too. Introduction To learn more ab

  • CURRENTLY NOT COMPATIBLE TO THE AETERNITY NETWORK This implementation aims to be a aims to be a full node that complies with the aeternity specification, in the current state this is not ready yet and