You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The range of values an integer type can represent depends on its signedness and its width, in bits. The width of type `uN` or `iN` is `N`. The width of type `usize` or `isize` is the value of the `target_pointer_width` property.
71
71
72
72
> [!NOTE]
73
-
> There are exactly `1<<N` unique values of an integer type of width `N`.
73
+
> There are exactly `1<<N` unique values of an integer type of width `N`.
74
74
> In particular, for an unsigned type, these values are in the range `0..(1<<N)` and for a signed type, are in the range `-(1<<(N-1))..(1<<(N-1))`, using rust range syntax.
75
75
76
76
r[type.numeric.repr.unsigned]
@@ -88,19 +88,19 @@ r[type.numeric.repr.signed]
88
88
A value `i` of a signed integer type with width `N` is represented the same as the corresponding value of the unsigned counterpart type which is congruent modulo `2^N`.
89
89
90
90
> [!NOTE]
91
-
> This encoding of signed integers is known as the 2s complement encoding.
91
+
> This encoding of signed integers is known as the 2s complement encoding.
92
92
93
93
r[type.numeric.repr.float-width]
94
94
Each floating-point type has a width. The type `fN` has a width of `N`.
95
95
96
96
r[type.numeric.repr.float]
97
97
A floating-point value is represented by the following decoding:
98
98
* The byte sequence is decoded as the unsigned integer type with the same width as the floating-point type,
99
-
* The resulting integer is decoded according to [IEEE 754-2019] into the format used for the type.
99
+
* The resulting integer is decoded according to [IEEE 754-2019] into the format used for the type.
100
100
101
101
> [!NOTE]
102
-
> The representation of each finite number and infinity is unique as a result of this.
103
-
> The exact behaviour of encoding and decoding NaNs is not yet decided
102
+
> The representation of each finite number and infinity is unique as a result of the definition of [IEEE 754-2019].
103
+
> The exact behaviour of encoding and decoding NaNs is not yet decided
104
104
105
105
r[type.numeric.repr.float-format]
106
106
The [IEEE 754-2019]`binary32` format is used for `f32`, and the `binary64` format is used for `f64`. The set of values for each floating-point type are determined by the respective format.
Copy file name to clipboardExpand all lines: src/types/struct.md
+1-5Lines changed: 1 addition & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,13 +36,9 @@ r[type.struct.value]
36
36
r[type.struct.value.intro]
37
37
A value of a struct type consists of a list of values for each field.
38
38
39
-
40
39
r[type.struct.value.encode-decode]
41
40
When a value of a struct type is encoded, each field of the struct is encoded at its corresponding offset and each byte that is not within a field of the struct is set to uninit.
42
-
When a value of a struct type is decoded, each field of the struct is decoded from its corresponding offset.
43
-
44
-
> [!NOTE]
45
-
> It is valid for padding bytes to hold a value other than uninit when decoded, and these bytes are ignored when decoding an struct value.
41
+
When a value of a struct type is decoded, each field of the struct is decoded from its corresponding offset. Each byte that is not within a field of the struct is ignored.
46
42
47
43
[^structtype]: `struct` types are analogous to `struct` types in C, the
48
44
*record* types of the ML family, or the *struct* types of the Lisp family.
Copy file name to clipboardExpand all lines: src/types/union.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ The memory layout of a `union` is undefined by default (in particular, fields do
24
24
*not* have to be at offset 0), but the `#[repr(...)]` attribute can be used to
25
25
fix a layout.
26
26
27
-
## Union Values
27
+
## Union Values
28
28
29
29
r[type.union.value]
30
30
@@ -37,7 +37,7 @@ A byte `b` in the representation of a struct or union is a value byte if there e
37
37
> [!NOTE]
38
38
> A byte in a union is a value byte if it is a value byte in *any* field.
39
39
40
-
r[type.struct.value.padding]
40
+
r[type.union.value.padding]
41
41
Every byte in an struct or union which is not a value byte is a padding byte. [Enum types][type.enum.value.value-padding], [tuple types][type.tuple.padding], and other types may also have padding bytes.
0 commit comments