# Feature Request: const float functions

**URL:** <https://internals.rust-lang.org/t/feature-request-const-float-functions/21063>\
**Category:** Uncategorized\
**Created:** [June 21, 2024, 6:24pm UTC](https://internals.rust-lang.org/t/feature-request-const-float-functions/21063 "2024-06-21T18:24:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![uzytkownik](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/uzytkownik/32/5013_2.png) [@uzytkownik](https://internals.rust-lang.org/u/uzytkownik)\
**Post date:** [June 21, 2024, 6:24pm UTC](https://internals.rust-lang.org/t/feature-request-const-float-functions/21063/1 "2024-06-21T18:24:44Z")

</div>

Currently the f32 and f64 functions are not const. In most cases they could be made const so that Rust can perform compile-time computations on floas.

---

<div class="post-metadata">

**Author:** ![toc](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/toc/32/6692_2.png) [@toc](https://internals.rust-lang.org/u/toc)\
**Post date:** [June 21, 2024, 6:35pm UTC](https://internals.rust-lang.org/t/feature-request-const-float-functions/21063/2 "2024-06-21T18:35:30Z")

</div>

This is an ongoing project.

> <https://github.com/rust-lang/rust/issues/57241>
>
> Sub-tracking issue for rust-lang/rfcs#911.
> 
> This tracks arithmetic for floatin…g point types in \`const fn\`. These operations are already stable in \`const\`/\`static\`, and are also being promoted on stable (\`&(1.2\*2.1)\` has lifetime \`'static\`). However, in all of these situations, the code is \*definitely\* executed at compile-time -- only \`const fn\` code could be executed \*both\* at compile-time and run-time, making possible differences in FP behavior observable. Also see https://github.com/rust-lang/rust/issues/77745.
> 
> \## Open Questions
> 
> \* https://github.com/rust-lang/rust/issues/77745: Must a \`const fn\` behave exactly the same at runtime as at compile-time?
> \* See https://github.com/rust-lang/unsafe-code-guidelines/issues/237 for a collection of issues around floating-point semantics.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [September 19, 2024, 6:35pm UTC](https://internals.rust-lang.org/t/feature-request-const-float-functions/21063/3 "2024-09-19T18:35:40Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
