gpt4 book ai didi

erlang - 16#00 是什么意思?

转载 作者:行者123 更新时间:2023-12-02 01:08:38 25 4
gpt4 key购买 nike

看看这个erlang file中的代码有一个这样的函数:

socket_type_atom(16#00) ->      pair;
socket_type_atom(16#01) -> pub;
socket_type_atom(16#02) -> sub;
socket_type_atom(16#03) -> req;
socket_type_atom(16#04) -> rep;
socket_type_atom(16#05) -> dealer;
socket_type_atom(16#06) -> router;
socket_type_atom(16#07) -> pull;
socket_type_atom(16#08) -> push.

根据我对 erlang 整数表示法的理解,5#10 表示以 10 为基数的整数 5。那么 16#00 代表什么?

最佳答案

documentation 中所述:

There are two types of numeric literals, integers and floats. Besides the conventional notation, there are two Erlang-specific notations:

$char
ASCII value or unicode code-point of the character char.

base#value
Integer with the base base, that must be an integer in the range 2..36.
In Erlang 5.2/OTP R9B and earlier versions, the allowed range is 2..16.

因此,16#number 只是十六进制的number。例如:

1> 16#10 == 16.
true

或二进制:

2> 2#11111111.
255

关于erlang - 16#00 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35608846/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com