langref: Add table of largest integer types that can coerce to floats

Add vertical margin to the `.table-wrapper` class so that there's space
between the table and the test figures. It does not affect any of the
existing tables because the margin collapses with the adjacent `<p>`.
This commit is contained in:
Jay Petacat
2026-01-24 11:49:26 -07:00
committed by Andrew Kelley
parent 1b235540c1
commit 97986184ca
+37
View File
@@ -128,6 +128,7 @@
}
.table-wrapper {
width: 100%;
margin: 1em auto;
overflow-x: auto;
}
@@ -3471,6 +3472,42 @@ void do_a_thing(struct Foo *foo) {
without rounding (i.e. the integer's precision does not exceed the float's significand precision).
Larger integer types that cannot be safely coerced must be explicitly casted with {#link|@floatFromInt#}.
</p>
<div class="table-wrapper">
<table>
<thead>
<tr>
<th scope="col">Float Type</th>
<th scope="col">Largest Integer Types</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">{#syntax#}f16{#endsyntax#}</th>
<td>{#syntax#}i12{#endsyntax#} and {#syntax#}u11{#endsyntax#}</td>
</tr>
<tr>
<th scope="row">{#syntax#}f32{#endsyntax#}</th>
<td>{#syntax#}i25{#endsyntax#} and {#syntax#}u24{#endsyntax#}</td>
</tr>
<tr>
<th scope="row">{#syntax#}f64{#endsyntax#}</th>
<td>{#syntax#}i54{#endsyntax#} and {#syntax#}u53{#endsyntax#}</td>
</tr>
<tr>
<th scope="row">{#syntax#}f80{#endsyntax#}</th>
<td>{#syntax#}i65{#endsyntax#} and {#syntax#}u64{#endsyntax#}</td>
</tr>
<tr>
<th scope="row">{#syntax#}f128{#endsyntax#}</th>
<td>{#syntax#}i114{#endsyntax#} and {#syntax#}u113{#endsyntax#}</td>
</tr>
<tr>
<th scope="row">{#syntax#}c_longdouble{#endsyntax#}</th>
<td>Varies by target</td>
</tr>
</tbody>
</table>
</div>
{#code|test_int_to_float_coercion.zig#}
{#code|test_failed_int_to_float_coercion.zig#}