diff options
| author | Graydon Hoare <[email protected]> | 2010-07-29 16:04:22 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2010-07-29 16:04:22 -0700 |
| commit | e08ed23a8061703b76230c15e053da67e7473a11 (patch) | |
| tree | d46130c9ec6db80c0ec30def75bbb9de61367b43 /doc | |
| parent | Log join-wait count under rust_log::TASK bits, not ::ALL. (diff) | |
| download | rust-e08ed23a8061703b76230c15e053da67e7473a11.tar.xz rust-e08ed23a8061703b76230c15e053da67e7473a11.zip | |
Make note of new literal forms in docs.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/rust.texi | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/doc/rust.texi b/doc/rust.texi index 3ad445d2..3aa079d7 100644 --- a/doc/rust.texi +++ b/doc/rust.texi @@ -756,6 +756,19 @@ and @emph{underscores}. @end enumerate +By default, an integer literal is of type @code{int}. An integer literal may +be followed (immediately, without any spaces) by a @dfn{integer suffix}, which +changes the type of the literal. There are three kinds of integer literal +suffix: + +@enumerate +@item The @code{u} suffix gives the literal type @code{uint}. +@item The @code{g} suffix gives the literal type @code{big}. +@item Each of the signed and unsigned machine types @code{u8}, @code{i8}, +@code{u16}, @code{i16}, @code{u32}, @code{i32}, @code{u64} and @code{i64} +give the literal the corresponding machine type. +@end enumerate + @sp 1 A @dfn{floating-point literal} has one of two forms: @enumerate @@ -765,6 +778,13 @@ second @emph{decimal literal}. @item A single @emph{decimal literal} followed by an @emph{exponent}. @end enumerate +By default, a floating-point literal is of type @code{float}. A floating-point +literal may be followed (immediately, without any spaces) by a +@dfn{floating-point suffix}, which changes the type of the literal. There are +only two floating-point suffixes: @code{f32} and @code{f64}. Each of these +gives the floating point literal the associated type, rather than +@code{float}. + @sp 1 A @dfn{hex digit} is either a @emph{decimal digit} or else a character in the ranges U+0061-U+0066 and U+0041-U+0046 (@code{'a'}-@code{'f'}, @@ -779,6 +799,28 @@ followed by a trailing @emph{decimal literal}. A @dfn{sign character} is either U+002B or U+002D (@code{'+'} or @code{'-'}). + +Examples of integer literals of various forms: +@example +123; // type int +123u; // type uint +123_u; // type uint +0xff00; // type int +0xffu8; // type u8 +0b1111_1111_1001_0000_i32; // type i32 +0xffff_ffff_ffff_ffff_ffff_ffffg; // type big +@end example + + +Examples of floating-point literals of various forms: +@example +123.0; // type float +0.1; // type float +0.1f32; // type f32 +12E+99_f64; // type f64 +@end example + + @node Ref.Lex.Text @subsection Ref.Lex.Text @c * Ref.Lex.Key:: String and character tokens. @@ -1314,8 +1356,8 @@ Other operations act on box values as single-word-sized address values, automatically adjusting reference counts on the associated heap allocation. For these operations, to access the value held in the box requires an explicit dereference of the box value. Explicitly dereferencing a box is -indicated with the @emph{star} sigil @code{*}. Examples of such @dfn{explicit -dererence} operations are: +indicated with the unary @emph{star} operator @code{*}. Examples of such +@dfn{explicit dererence} operations are: @itemize @item copying box values (@code{x = y}) @item passing box values to functions (@code{f(x,y)}) |