# Why does Swift not support rational numbers?

**URL:** <https://forums.swift.org/t/why-does-swift-not-support-rational-numbers/62725>\
**Category:** Using Swift\
**Tags:** numbers\
**Created:** [January 22, 2023, 6:20am UTC](https://forums.swift.org/t/why-does-swift-not-support-rational-numbers/62725 "2023-01-22T06:20:09Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![tera](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tera/32/38201_2.png) [@tera](https://forums.swift.org/u/tera)\
**Post date:** [January 23, 2023, 1:58am UTC](https://forums.swift.org/t/why-does-swift-not-support-rational-numbers/62725/5 "2023-01-23T01:58:05Z")

</div>

I believe OP actually meant "fixed" point math hence the usage of 32/64 bit UInt for both numerator and denominator in the leading example:

```
typealias NaturalNumber = Uint
let numerator : NaturalNumber
let denominator: NaturalNumber

```

I would welcome first class support for Fixed numbers. Don't do finance, but hate when I see floating point gotchas in graphics, e.g. [rect math acting weirdly](https://forums.swift.org/t/cgrect-intersection-gives-surprising-result-due-to-floating-point-arithmetic/21336) because of this:

```swift
let a = 100.33333333333333333333333
let b = a + 100
let c = b - 100
assert(a == c) // Assertion failed

```

---

_[View the full topic](https://forums.swift.org/t/why-does-swift-not-support-rational-numbers/62725)._
