commit 97986184ca67abdb877bda39707dd129ed6473ae (tree) parent 1b235540c1d1acdd59aee3c2a8756bc7f0fa55a3 Author: Jay Petacat <jay@jayschwa.net> Date: Sat, 24 Jan 2026 11:49:26 -0700 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>`. Diffstat:
| M | doc/langref.html.in | | | 37 | +++++++++++++++++++++++++++++++++++++ |
1 file changed, 37 insertions(+), 0 deletions(-)
diff --git a/doc/langref.html.in b/doc/langref.html.in @@ -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#}