authorgravatar for jay@jayschwa.netJay Petacat <jay@jayschwa.net> 2026-01-24 11:49:26-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-26 23:52:30+01:00
log97986184ca67abdb877bda39707dd129ed6473ae
treeb2df7703ba82edac4c3dfa8e74ee3d9b073639f0
parent1b235540c1d1acdd59aee3c2a8756bc7f0fa55a3

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>`.

1 files changed, 37 insertions(+), 0 deletions(-)

doc/langref.html.in+37
...@@ -128,6 +128,7 @@...@@ -128,6 +128,7 @@
128 }128 }
129 .table-wrapper {129 .table-wrapper {
130 width: 100%;130 width: 100%;
131 margin: 1em auto;
131 overflow-x: auto;132 overflow-x: auto;
132 }133 }
133134
...@@ -3471,6 +3472,42 @@ void do_a_thing(struct Foo *foo) {...@@ -3471,6 +3472,42 @@ void do_a_thing(struct Foo *foo) {
3471 without rounding (i.e. the integer's precision does not exceed the float's significand precision).3472 without rounding (i.e. the integer's precision does not exceed the float's significand precision).
3472 Larger integer types that cannot be safely coerced must be explicitly casted with {#link|@floatFromInt#}.3473 Larger integer types that cannot be safely coerced must be explicitly casted with {#link|@floatFromInt#}.
3473 </p>3474 </p>
3475 <div class="table-wrapper">
3476 <table>
3477 <thead>
3478 <tr>
3479 <th scope="col">Float Type</th>
3480 <th scope="col">Largest Integer Types</th>
3481 </tr>
3482 </thead>
3483 <tbody>
3484 <tr>
3485 <th scope="row">{#syntax#}f16{#endsyntax#}</th>
3486 <td>{#syntax#}i12{#endsyntax#} and {#syntax#}u11{#endsyntax#}</td>
3487 </tr>
3488 <tr>
3489 <th scope="row">{#syntax#}f32{#endsyntax#}</th>
3490 <td>{#syntax#}i25{#endsyntax#} and {#syntax#}u24{#endsyntax#}</td>
3491 </tr>
3492 <tr>
3493 <th scope="row">{#syntax#}f64{#endsyntax#}</th>
3494 <td>{#syntax#}i54{#endsyntax#} and {#syntax#}u53{#endsyntax#}</td>
3495 </tr>
3496 <tr>
3497 <th scope="row">{#syntax#}f80{#endsyntax#}</th>
3498 <td>{#syntax#}i65{#endsyntax#} and {#syntax#}u64{#endsyntax#}</td>
3499 </tr>
3500 <tr>
3501 <th scope="row">{#syntax#}f128{#endsyntax#}</th>
3502 <td>{#syntax#}i114{#endsyntax#} and {#syntax#}u113{#endsyntax#}</td>
3503 </tr>
3504 <tr>
3505 <th scope="row">{#syntax#}c_longdouble{#endsyntax#}</th>
3506 <td>Varies by target</td>
3507 </tr>
3508 </tbody>
3509 </table>
3510 </div>
3474 {#code|test_int_to_float_coercion.zig#}3511 {#code|test_int_to_float_coercion.zig#}
3475 {#code|test_failed_int_to_float_coercion.zig#}3512 {#code|test_failed_int_to_float_coercion.zig#}
34763513