Movatterモバイル変換


[0]ホーム

URL:



Lady Ada

Ada '83 Language Reference Manual

Copyright 1980, 1982, 1983 owned by the United States Government. Direct reproduction and usage requests to theAda Information Clearinghouse.


2.4. Numeric Literals

[PREVIOUS][UP][NEXT]

There are two classes of numeric literals: real literals and integerliterals. A real literal is a numeric literal that includes a point; aninteger literal is a numeric literal without a point. Real literals arethe literals of the type universal_real. Integer literals are the literalsof the type universal_integer.

    numeric_literal ::= decimal_literal | based_literal

References:literal,universal_integer type,universal_real type.

Rationale references:2.1 Lexical Structure

Sub-topics:

2.4.1. Decimal Literals

[UP][NEXT]

A decimal literal is a numeric literal expressed in the conventionaldecimal notation (that is, the base is implicitly ten).

    decimal_literal ::= integer [.integer] [exponent]     integer  ::= digit {[underline] digit}     exponent ::= E [+] integer | E - integer

An underline character inserted between adjacent digits of a decimalliteral does not affect the value of this numeric literal. The letter E ofthe exponent, if any, can be written either in lower case or in upper case,with the same meaning.

An exponent indicates the power of ten by which the value of the decimalliteral without the exponent is to be multiplied to obtain the value of thedecimal literal with the exponent. An exponent for an integer literal mustnot have a minus sign.

Examples:

    12        0      1E6    123_456     --  integer literals     12.0      0.0    0.456  3.14159_26  --  real literals     1.34E-12  1.0E+6  --  real literals with exponent

Notes:

Leading zeros are allowed. No space is allowed in a numeric literal, noteven between constituents of the exponent, since a space is a separator. Azero exponent is allowed for an integer literal.

References:digit,lower case letter,numeric literal,separator,space character,upper case letter.

2.4.2. Based Literals

[PREVIOUS][UP]

A based literal is a numeric literal expressed in a form that specifies thebase explicitly. The base must be at least two and at most sixteen.

    based_literal ::=       base # based_integer [.based_integer] # [exponent]     base ::= integer     based_integer ::=       extended_digit {[underline] extended_digit}     extended_digit ::= digit | letter

An underline character inserted between adjacent digits of a based literaldoes not affect the value of this numeric literal. The base and theexponent, if any, are in decimal notation. The only letters allowed asextended digits are the letters A through F for the digits ten throughfifteen. A letter in a based literal (either an extended digit or theletter E of an exponent) can be written either in lower case or in uppercase, with the same meaning.

The conventional meaning of based notation is assumed; in particular thevalue of each extended digit of a based literal must be less than the base.An exponent indicates the power of the base by which the value of the basedliteral without the exponent is to be multiplied to obtain the value of thebased literal with the exponent.

Examples:

  2#1111_1111#   16#FF#       016#0FF#    --  integer literals of value 255  16#E#E1        2#1110_0000 #            --  integer literals of value 224  16#F.FF#E+2    2#1.1111_1111_111#E11    --  real literals of value 4095.0

References:digit,exponent,letter,lower case letter,numeric literal,upper case letter.

Style Guide references:3.1.2 Numbers,3.2.5 Constants and Named Numbers,7.2.6 Precision of Constants

[INDEX][CONTENTS]


[Ada Information Clearinghouse]

Address any questions or comments toadainfo@sw-eng.falls-church.va.us.


[8]ページ先頭

©2009-2025 Movatter.jp