Complex number functions for std.math

James Dunne james.jdunne at gmail.com
Sun Apr 9 00:29:27 PDT 2006


Dave wrote:
> In article <e15v1k$1qnu$1 at digitaldaemon.com>, James Dunne says...
> 
>>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.
>>
> 
> 
> Since 'float' is included as an alias that C/++ programmers would be familiar
> with, I like this scheme, except 'extended' isn't intuitive, especially on
> machines that don't support > 64 bit fp.
> 
> Any ideas there?
> 
> 
>>-- 
>>-----BEGIN GEEK CODE BLOCK-----
>>Version: 3.1
>>GCS/MU/S d-pu s:+ a-->? C++++$ UL+++ P--- L+++ !E W-- N++ o? K? w--- O 
>>M--@ V? PS PE Y+ PGP- t+ 5 X+ !R tv-->!tv b- DI++(+) D++ G e++>e 
>>h>--->++ r+++ y+++
>>------END GEEK CODE BLOCK------
>>
>>James Dunne
> 
> 

I guess...

	half
	single
	double
	twopt5
	quad

:)

But seriously though, I used 'extended' since it came from Borland's 
Pascal which I was familiar with up until I learned C - it was a great 
transition between BASIC and C.  (see 
http://www.merlyn.demon.co.uk/pas-real.htm#FloatTypes)

I tend to favor the numbering scheme by postfixing the number of bits 
required by the type to the base name of the type:

	float16
	float32
	float64
	float80
	float128

Perhaps these should be the base types with 'single', 'double', and 
'extended' as aliases for the common ones?

-- 
Regards,
James Dunne



More information about the Digitalmars-d mailing list