<!--
{
  "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/BinaryFloatingPoint",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:SB"
  },
  "title" : "BinaryFloatingPoint"
}
-->

# BinaryFloatingPoint

A radix-2 (binary) floating-point type.

```
protocol BinaryFloatingPoint : ExpressibleByFloatLiteral, FloatingPoint
```

## Overview

The `BinaryFloatingPoint` protocol extends the `FloatingPoint` protocol
with operations specific to floating-point binary types, as defined by the
[IEEE 754 specification](http://ieeexplore.ieee.org/servlet/opac?punumber=4610933). `BinaryFloatingPoint` is implemented in
the standard library by `Float`, `Double`, and `Float80` where available.

## Topics

### Converting Floating-Point Values

[`init(_:)`](/documentation/Swift/BinaryFloatingPoint/init(_:)-57jx7)

Creates a new instance from the given value, rounded to the closest
possible representation.

[`init(_:)`](/documentation/Swift/BinaryFloatingPoint/init(_:)-7ft14)

Creates a new instance from the given value, rounded to the closest
possible representation.

[`init(_:)`](/documentation/Swift/BinaryFloatingPoint/init(_:)-1nijh)

Creates a new instance from the given value, rounded to the closest
possible representation.

[`init(_:)`](/documentation/Swift/BinaryFloatingPoint/init(_:)-shau)

Creates a new instance from the given value, rounded to the closest
possible representation.

### Converting with No Loss of Precision

[`init(exactly:)`](/documentation/Swift/BinaryFloatingPoint/init(exactly:))

Creates a new instance from the given value, if it can be represented
exactly.

### Creating a Random Value

[`random(in:)`](/documentation/Swift/BinaryFloatingPoint/random(in:)-2j16p)

Returns a random value within the specified range.

[`random(in:)`](/documentation/Swift/BinaryFloatingPoint/random(in:)-8jkjb)

Returns a random value within the specified range.

[`random(in:using:)`](/documentation/Swift/BinaryFloatingPoint/random(in:using:)-6pf7f)

Returns a random value within the specified range, using the given
generator as a source for randomness.

[`random(in:using:)`](/documentation/Swift/BinaryFloatingPoint/random(in:using:)-2awm8)

Returns a random value within the specified range, using the given
generator as a source for randomness.

### Working with Binary Representation

[`binade`](/documentation/Swift/BinaryFloatingPoint/binade)

The floating-point value with the same sign and exponent as this value,
but with a significand of 1.0.

[`exponentBitPattern`](/documentation/Swift/BinaryFloatingPoint/exponentBitPattern)

The raw encoding of the value’s exponent field.

[`significandBitPattern`](/documentation/Swift/BinaryFloatingPoint/significandBitPattern)

The raw encoding of the value’s significand field.

[`significandWidth`](/documentation/Swift/BinaryFloatingPoint/significandWidth)

The number of bits required to represent the value’s significand.

[`exponentBitCount`](/documentation/Swift/BinaryFloatingPoint/exponentBitCount)

The number of bits used to represent the type’s exponent.

[`significandBitCount`](/documentation/Swift/BinaryFloatingPoint/significandBitCount)

The available number of fractional significand bits.

[`init(sign:exponentBitPattern:significandBitPattern:)`](/documentation/Swift/BinaryFloatingPoint/init(sign:exponentBitPattern:significandBitPattern:))

Creates a new instance from the specified sign and bit patterns.

[`RawExponent`](/documentation/Swift/BinaryFloatingPoint/RawExponent)

A type that represents the encoded exponent of a value.

[`RawSignificand`](/documentation/Swift/BinaryFloatingPoint/RawSignificand)

A type that represents the encoded significand of a value.



---

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)