如何获得长生不老药中每种类型的最小值和最大值
How to get minimum and maximum value of each type in elixir
如何获取elixir中每种类型的最小值和最大值?例如整数、浮点数和字符串的最大可能长度。
我知道在 C 中它在 limits.h
中被定义为 INT_MIN
、INT_MAX
等等。关于长生不老药中这些类型的限制的文档在哪里?
Elixir(实际上是 Erlang)使用 bignum arithmetic,这是计算机科学中使用的一种算术,其中(引用维基百科)
calculations are performed on numbers whose digits of precision are limited only by the available memory of the host system
Erlang 文档中有 a page 讨论了 Erlang VM 的限制(例如,atom 最多可以有 255 个字符);如您所见,如果您查看该页面,甚至都没有提到整数限制。
Erlang/Elixir 中的整数仅受系统可用内存的限制,因此实际上没有限制它们的大小。
对于二进制文件(字符串),我将只引用上面链接的页面所说的内容:
In the 32-bit implementation of Erlang, 536870911 bytes is the largest binary that can be constructed or matched using the bit syntax. (In the 64-bit implementation, the maximum size is 2305843009213693951 bytes.) If the limit is exceeded, bit syntax construction will fail with a system_limit exception, while any attempt to match a binary that is too large will fail. This limit is enforced starting with the R11B-4 release; in earlier releases, operations on too large binaries would in general either fail or give incorrect results. In future releases of Erlang/OTP, other operations that create binaries (such as list_to_binary/1) will probably also enforce the same limit.
如何获取elixir中每种类型的最小值和最大值?例如整数、浮点数和字符串的最大可能长度。
我知道在 C 中它在 limits.h
中被定义为 INT_MIN
、INT_MAX
等等。关于长生不老药中这些类型的限制的文档在哪里?
Elixir(实际上是 Erlang)使用 bignum arithmetic,这是计算机科学中使用的一种算术,其中(引用维基百科)
calculations are performed on numbers whose digits of precision are limited only by the available memory of the host system
Erlang 文档中有 a page 讨论了 Erlang VM 的限制(例如,atom 最多可以有 255 个字符);如您所见,如果您查看该页面,甚至都没有提到整数限制。
Erlang/Elixir 中的整数仅受系统可用内存的限制,因此实际上没有限制它们的大小。
对于二进制文件(字符串),我将只引用上面链接的页面所说的内容:
In the 32-bit implementation of Erlang, 536870911 bytes is the largest binary that can be constructed or matched using the bit syntax. (In the 64-bit implementation, the maximum size is 2305843009213693951 bytes.) If the limit is exceeded, bit syntax construction will fail with a system_limit exception, while any attempt to match a binary that is too large will fail. This limit is enforced starting with the R11B-4 release; in earlier releases, operations on too large binaries would in general either fail or give incorrect results. In future releases of Erlang/OTP, other operations that create binaries (such as list_to_binary/1) will probably also enforce the same limit.