Complex number functions for std.math
Don Clugston
dac at nospam.com.au
Fri Apr 7 08:41:43 PDT 2006
James Dunne wrote:
> Don Clugston wrote:
>> Norbert Nemec wrote:
>>> (Sorry for writing "complex" instead of the monstrosity "creal". My
>>> fingers just don't obey me when I command them to write about a
>>> "complex real" number. Of course, "creal" could also stand for "really
>>> complex". But then "real" should be renamed into "cnreal", standing for
>>> "not really complex"...)
>>
>> It is a bit of an oxymoron. I do like the idea of having 'complex' as
>> a standard alias in std.math. It should operate almost as a reserved
>> word, users should not be defining it to be anything other than creal.
>> But I would not like to have to type "imaginary" instead of "ireal" --
>> it's just too long. Any ideas on that one?
>>
>
> Here's what I've devised for a floating-point type system similar to D's:
>
> single - real single-precision (32-bit) IEEE 754 floating point
> isingle - imaginary single-precision (32-bit) IEEE 754 floating poi$
> csingle - complex single
>
> double - real double-precision (64-bit) IEEE 754 floating point
> idouble - imaginary double-precision (64-bit) IEEE 754 floating poi$
> cdouble - complex double
>
> extended - real extended-precision (80-bit) IEEE 754 floating point
> iextended - imaginary extended-precision (80-bit) IEEE 754 floating point
> cextended - complex extended
>
> float - alias for single
> ifloat - alias for isingle
> cfloat - alias for csingle
>
> Notably, the float has been renamed to single, and real has been renamed
> to extended. Float still lurks around as an alias for single though.
Something that I *really* like about 'real' is that it's short, so it
becomes used by default. I think with your naming scheme, everyone would
use double by default.
If we could start afresh, the best way I think would be to have single,
double, extended, and have 'float' as an alias for extended.
Unfortunately, 'float' is too heavily entrenched as a low-precision
floating point number.
More information about the Digitalmars-d
mailing list