# Working with reals near the machine precision

**URL:** <https://fortran-lang.discourse.group/t/working-with-reals-near-the-machine-precision/5590>\
**Category:** Help\
**Created:** [April 16, 2023, 12:48pm UTC](https://fortran-lang.discourse.group/t/working-with-reals-near-the-machine-precision/5590 "2023-04-16T12:48:30Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [April 19, 2023, 1:20pm UTC](https://fortran-lang.discourse.group/t/working-with-reals-near-the-machine-precision/5590/18 "2023-04-19T13:20:16Z")

</div>

> [@PierU](#):
>
> I was doing an interative bisection `v0 = (v1+v2)/2`, and it was more efficient to let it continue until possibly an interval as small as the spacing between 2 representable reals. So I wanted to be sure about what was happening at this scale.

That’s a common case, which I even mention here: [schools.rst · GitHub](https://gist.github.com/certik/89dcc5bccf041ce1f57f1533c6a5d9e0#bisection-stopping-condition) (linked in this thread: [Can one design coding rules to follow so that `-ffast-math` is safe?](https://fortran-lang.discourse.group/t/can-one-design-coding-rules-to-follow-so-that-ffast-math-is-safe/2762)).

You CAN do it your way, but then you have to go the extra length to ensure things behave correctly bit to bit, which I call the IEEE school of thought. This approach has pros and cons. If you want to use the other approach, then just adjust your epsilon to be larger than just nearest spacing, and things should be robust and fast (and accurate enough).

---

_[View the full topic](https://fortran-lang.discourse.group/t/working-with-reals-near-the-machine-precision/5590)._
