# Complex Numbers (Pre-ACP)

**URL:** https://internals.rust-lang.org/t/complex-numbers-pre-acp/23769
**Category:** language design
**Created:** [November 25, 2025, 10:15am UTC](https://internals.rust-lang.org/t/complex-numbers-pre-acp/23769 "2025-11-25T10:15:03Z")
**Posts on this page:** 7
**Page:** 2

<div class="post-metadata">

### Author: ![kornel](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/kornel/32/2711_2.png) [@kornel](https://internals.rust-lang.org/u/kornel)
#### Post date: [December 8, 2025, 2:26am UTC](https://internals.rust-lang.org/t/complex-numbers-pre-acp/23769/22 "2025-12-08T02:26:46Z")

</div>

If the primary reason for putting this in std is the C ABI, could this start as a type in `std::ffi::c_complex`?

---

<div class="post-metadata">

### Author: ![josh](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/josh/32/5934_2.png) [@josh](https://internals.rust-lang.org/u/josh)
#### Post date: [December 8, 2025, 5:44am UTC](https://internals.rust-lang.org/t/complex-numbers-pre-acp/23769/23 "2025-12-08T05:44:09Z")

</div>

I don't think that's the _primary_ reason; the other reason is common vocabulary for Rust API.

---

<div class="post-metadata">

### Author: ![ais523](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@ais523](https://internals.rust-lang.org/u/ais523)
#### Post date: [December 8, 2025, 10:15am UTC](https://internals.rust-lang.org/t/complex-numbers-pre-acp/23769/24 "2025-12-08T10:15:00Z")

</div>

I've implemented complex numbers myself for a Rust program, and have a word of caution: rounding is a difficult problem when operating on complex numbers, both in terms of getting the correct result and in terms of even specifying what the desirable behavior is (there is more than one reasonable way to define it). Modulo and gcd are particularly difficult to specify sensibly (modulo is connected to the way that division rounds, which is two-dimensional; and gcd has four possible signs for the result, and often none of them are "positive" which is what you'd usually want). This is probably fixable, but needs to be thought about in advance in order to avoid causing problems later.

---

<div class="post-metadata">

### Author: ![SciMind2460](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/scimind2460/32/13125_2.png) [@SciMind2460](https://internals.rust-lang.org/u/SciMind2460)
#### Post date: [December 8, 2025, 11:05am UTC](https://internals.rust-lang.org/t/complex-numbers-pre-acp/23769/25 "2025-12-08T11:05:20Z")

</div>

Isn't that mostly for Gaussian integers? This RFC has been limited to floating points for now.

---

<div class="post-metadata">

### Author: ![ais523](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@ais523](https://internals.rust-lang.org/u/ais523)
#### Post date: [December 8, 2025, 11:21am UTC](https://internals.rust-lang.org/t/complex-numbers-pre-acp/23769/26 "2025-12-08T11:21:17Z")

</div>

Modulo and GCD are both definable on floating-point numbers (but require reasoning about integers to define them), and modulo is supported by floating-point real numbers in Rust at the moment (so people would probably expect it to work on complex numbers too, although perhaps it could be left out of an initial implementation).

Rounding is also very relevant for floating-point numbers in general, anyway (including complex floats) – they're quantized in the same way that integers are (and in some ranges support only integer values).

---

<div class="post-metadata">

### Author: ![Vorpal](https://avatars.discourse-cdn.com/v4/letter/v/aca169/32.png) [@Vorpal](https://internals.rust-lang.org/u/Vorpal)
#### Post date: [December 8, 2025, 12:18pm UTC](https://internals.rust-lang.org/t/complex-numbers-pre-acp/23769/27 "2025-12-08T12:18:25Z")

</div>

Shouldn't there be two complex types also: cartesian and polar?

(Also, is the concept of integers in the complex plane even well defined? That will work differently between cartesian and polar. )

---

<div class="post-metadata">

### Author: ![pitaj](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/pitaj/32/11262_2.png) [@pitaj](https://internals.rust-lang.org/u/pitaj)
#### Post date: [December 8, 2025, 3:43pm UTC](https://internals.rust-lang.org/t/complex-numbers-pre-acp/23769/28 "2025-12-08T15:43:38Z")

</div>

Polar isn't really useful for calculations, so I'd just expect to see functions `abs` and `theta` for calculating the polar form.

[Previous page](https://internals.rust-lang.org/t/complex-numbers-pre-acp/23769.md?page=1)
