<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Double/remainder(dividingBy:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:SFsE9remainder10dividingByxx_tF::SYNTHESIZED::s:Sd"
  },
  "title" : "remainder(dividingBy:)"
}
-->

# remainder(dividingBy:)

Returns the remainder of this value divided by the given value.

```
func remainder(dividingBy other: Self) -> Self
```

## Parameters

`other`

The value to use when dividing this value.

## Return Value

The remainder of this value divided by `other`.

## Discussion

For two finite values `x` and `y`, the remainder `r` of dividing `x` by
`y` satisfies `x == y * q + r`, where `q` is the integer nearest to
`x / y`. If `x / y` is exactly halfway between two integers, `q` is
chosen to be even. Note that `q` is *not* `x / y` computed in
floating-point arithmetic, and that `q` may not be representable in any
available integer type.

The following example calculates the remainder of dividing 8.625 by 0.75:

```
let x = 8.625
print(x / 0.75)
// Prints "11.5"

let q = (x / 0.75).rounded(.toNearestOrEven)
// q == 12.0
let r = x.remainder(dividingBy: 0.75)
// r == -0.375

let x1 = 0.75 * q + r
// x1 == 8.625
```

If this value and `other` are finite numbers, the remainder is in the
closed range `-abs(other / 2)...abs(other / 2)`. The
`remainder(dividingBy:)` method is always exact. This method implements
the remainder operation defined by the [IEEE 754 specification](http://ieeexplore.ieee.org/servlet/opac?punumber=4610933).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)