| ... | ... | @@ -370,17 +370,17 @@ pub fn main() void { |
| 370 | 370 | <tr> |
| 371 | 371 | <td><code>f32</code></td> |
| 372 | 372 | <td><code>float</code></td> |
| 373 | | <td>32-bit floating point (23-bit mantissa)</td> |
| 373 | <td>32-bit floating point (23-bit mantissa) IEEE-754-2008 binary32</td> |
| 374 | 374 | </tr> |
| 375 | 375 | <tr> |
| 376 | 376 | <td><code>f64</code></td> |
| 377 | 377 | <td><code>double</code></td> |
| 378 | | <td>64-bit floating point (52-bit mantissa)</td> |
| 378 | <td>64-bit floating point (52-bit mantissa) IEEE-754-2008 binary64</td> |
| 379 | 379 | </tr> |
| 380 | 380 | <tr> |
| 381 | 381 | <td><code>f128</code></td> |
| 382 | 382 | <td>(none)</td> |
| 383 | | <td>128-bit floating point (112-bit mantissa)</td> |
| 383 | <td>128-bit floating point (112-bit mantissa) IEEE-754-2008 binary128</td> |
| 384 | 384 | </tr> |
| 385 | 385 | <tr> |
| 386 | 386 | <td><code>bool</code></td> |
| ... | ... | @@ -407,6 +407,16 @@ pub fn main() void { |
| 407 | 407 | <td>(none)</td> |
| 408 | 408 | <td>an error code</td> |
| 409 | 409 | </tr> |
| 410 | <tr> |
| 411 | <td><code>comptime_int</code></td> |
| 412 | <td>(none)</td> |
| 413 | <td>Only allowed for {#link|comptime#}-known values. The type of integer literals.</td> |
| 414 | </tr> |
| 415 | <tr> |
| 416 | <td><code>comptime_float</code></td> |
| 417 | <td>(none)</td> |
| 418 | <td>Only allowed for {#link|comptime#}-known values. The type of float literals.</td> |
| 419 | </tr> |
| 410 | 420 | </table> |
| 411 | 421 | </div> |
| 412 | 422 | {#see_also|Integers|Floats|void|Errors#} |
| ... | ... | @@ -642,7 +652,18 @@ fn divide(a: i32, b: i32) i32 { |
| 642 | 652 | {#header_close#} |
| 643 | 653 | {#header_close#} |
| 644 | 654 | {#header_open|Floats#} |
| 655 | <p>Zig has the following floating point types:</p> |
| 656 | <ul> |
| 657 | <li><code>f32</code> - IEEE-754-2008 binary32</li> |
| 658 | <li><code>f64</code> - IEEE-754-2008 binary64</li> |
| 659 | <li><code>f128</code> - IEEE-754-2008 binary128</li> |
| 660 | <li><code>c_longdouble</code> - matches <code>long double</code> for the target C ABI</li> |
| 661 | </ul> |
| 645 | 662 | {#header_open|Float Literals#} |
| 663 | <p> |
| 664 | Float literals have type <code>comptime_float</code> which is guaranteed to hold at least all possible values |
| 665 | that the largest other floating point type can hold. Float literals implicitly cast to any other type. |
| 666 | </p> |
| 646 | 667 | {#code_begin|syntax#} |
| 647 | 668 | const floating_point = 123.0E+77; |
| 648 | 669 | const another_float = 123.0; |