Comparison of Imaginary types

Nick Treleaven nick at geany.org
Fri Jul 10 15:21:08 UTC 2026


On Friday, 3 July 2026 at 08:58:48 UTC, Nick Treleaven wrote:
>> Where is the documentation on these deprecated ifloat and 
>> cfloat types please?
>
> AFAICT there wasn't really much in the spec, though I have 
> found this article comparing support to C++'s `complex` library 
> type:
> https://digitalmars.com/d/1.0/cppcomplex.html
>
> `ifloat` should work the same as a `float`, except it's a 
> different type which doesn't implicitly convert.

One difference is that `*=` with an imaginary (or complex) type 
on the right-hand side is not allowed:
```d
import std.stdio;

void main()
{
     ifloat i = 1i;
     i *= 2; // OK
     i.writeln; // 2i
     (i * i).writeln; // -4
     i *= i; // error
}
```

> ifloat.d(6): Error: `ifloat *= ifloat` is an undefined operation

Also Don made an argument why imaginary types are not needed in D:
https://forum.dlang.org/post/fmg01c$253i$1@digitalmars.com

(Thanks to Mike for thread link!)


More information about the Digitalmars-d-learn mailing list