# \`TryFrom\` for \`f64\`

**URL:** https://internals.rust-lang.org/t/tryfrom-for-f64/9793
**Category:** libs
**Created:** [April 9, 2019, 8:42am UTC](https://internals.rust-lang.org/t/tryfrom-for-f64/9793 "2019-04-09T08:42:02Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![Tom-Phinney](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/tom-phinney/32/3299_2.png) [@Tom-Phinney](https://internals.rust-lang.org/u/Tom-Phinney)
#### Post date: [April 9, 2019, 9:24pm UTC](https://internals.rust-lang.org/t/tryfrom-for-f64/9793/4 "2019-04-09T21:24:39Z")

</div>

> [@cuviper](#):
>
> This expectation makes me think #1 (nearest match) is fine.

Just be careful in the definition of "nearest". As with almost everything in IEEE floating point, such mathematical concepts are somewhat imprecise when realized within the constraints of the encoding. Is +0.0 "nearer" to 0u64 than -0.0? Is rounding "down" toward zero nearer than rounding "up"?

---

_[View the full topic](https://internals.rust-lang.org/t/tryfrom-for-f64/9793)._
