这来自在线Ada参考手册:http: //www.adaic.org/resources/add_content/standards/05rm/RM.pdf (第2.3节)
A decimal_literal is a numeric_literal in the conventional decimal notation (that is, the base is ten).
Syntax
decimal_literal ::= numeral [.numeral] [exponent]
**numeral ::= digit {[underline] digit}**
exponent ::= E [+] numeral | E – numeral
digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
An exponent for an integer literal shall not have a minus sign.
Static Semantics
**An underline character in a numeric_literal does not affect its meaning.** The letter E of an exponent can be
written either in lower case or in upper case, with the same meaning.
Run Code Online (Sandbox Code Playgroud)
如果我做
my_literal ::= 123_456;
Run Code Online (Sandbox Code Playgroud)
下划线(下划线)是什么意思?它说它不会影响意义.那它是什么?我确信有一个简单的答案,但阅读和重新审视这段话并没有帮助我.
例如,,货币或[其他大型]数字中的逗号()是相同的原因:分组.从而:
Million : Constant:= 1_000_000;
Run Code Online (Sandbox Code Playgroud)
此外,您可以将它与基本设置结合使用作为屏蔽设置:
Type Bit is Range 1..8;
SubType Byte is Interfaces.Unsigned_8;
Type Masks is Array(Positive Range <>) of Byte;
Mask_Map : Constant Masks(Bit):=
(
2#0000_0001#,
2#0000_0010#,
2#0000_0100#,
2#0000_1000#,
2#0001_0000#,
2#0010_0000#,
2#0100_0000#,
2#1000_0000#
);
Run Code Online (Sandbox Code Playgroud)
那么也许你会使用Mask_Map和位一起or,and和xor做位操作.上面的方法似乎比许多常量的简单定义和直接操作它们要多一些,但它更灵活,以后你可以将它改成一个函数而不必更改任何客户端代码,如果该函数的结果是参数化整数,其中bit具有定义,则更有用1..PARAMETER'Size.
| 归档时间: |
|
| 查看次数: |
467 次 |
| 最近记录: |