Skip to content

Commit

Permalink
deploy: 08066a9
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jun 29, 2024
1 parent 1d5d83f commit 4eb267b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/overview/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1681,11 +1681,11 @@ <h3 id=bit-fields>Bit Fields <a class=text-decoration-none href=#bit-fields>#</a
x: i32 | 3, // signed integers will be signed extended on use
y: u16 | 2 + 3, // general expressions
z: My_Enum | foo.SOME_CONSTANT, // ability to define the bit-width elsewhere
w: bool | foo.SOME_CONSTANT &gt; 10 ? 2 : 1,
w: bool | 2 when foo.SOME_CONSTANT &gt; 10 else 1,
}

v := Foo{}
v.x = 4 // truncates the value to fit into 3 bits
v.x = 3 // truncates the value to fit into 3 bits
fmt.println(v.x) // accessing will convert `v.x` to an `i32` and do an appropriate sign extension
</code></pre><p>A <code>bit_field</code> is different from a <code>struct</code> in that you must specify the backing type. This backing type must be an integer or a fixed-length array of integers. This is useful if there needs to be a specific alignment or access pattern for the record.</p>
<pre><code class=language-odin data-lang=odin>Foo :: bit_field u32 {...}
Expand Down

0 comments on commit 4eb267b

Please sign in to comment.