I need a function like this:

```
extension BinaryFloatingPoint {
func addingRoundingDown(_ incr: Self) -> Self {
// ...
}
}
```

(Note: This is *not* about rounding to integer values, it's about rounding to representable floating point values.)

Here's what I want it to do: Starting at the exact real result, return the first representable floating point value in direction towards negative infinity (unless the exact result is representable).

To be clear, the expected behavior is such that the following should be true:

```
Float(1).nextDown.addingRoundingDown(1) == Float(2).nextDown
```

Note that the behavior of the regular (round to nearest tie to even) addition operator is such that the following is true:

```
Float(1).nextDown + 1 == Float(2)
```

And this is not what I want.

I only need it to work for `self >= 0 && incr >= 0`

, although it would be nice if it worked for any values. I'd like it to be reasonably fast and work for any `BinaryFloatingPoint`

type though.

**What would be the best way to achieve this in Swift today** (perhaps by using the regular `+`

and some extra code to compensate for the default rounding, or by bit manipulation, or by using C)**?**

EDIT: I've read this old thread and the following will work for `Float32`

and `Float64`

, but not for `Float80`

for some reason, and only if it's annotated with `@inline(never)`

to prevent static evaluation using standard rounding, and I assume it will be quite slow to change the rounding mode at each call:

```
extension BinaryFloatingPoint {
@inline(never)
func addingRoundingDown(_ incr: Self) -> Self {
let savedRoundingMode = fegetround()
fesetround(FE_DOWNWARD)
let r = self + incr
fesetround(savedRoundingMode)
return r
}
}
```