From: Jeremy Maitin-Shepard (jbms_at_[hidden])
Date: 2003-12-13 20:41:42
"Mohamed Iqbal" <miqbal_at_[hidden]> writes:
>> Mohamed Iqbal wrote:
>> >>>26.2/2: The effect of instantiating the template complex for any type
>> >>> other than float, double or long double is unspecified.
>> >>Does anybody know the reason for that?
>> > Another reason is: some of the mathematical operations are not
> meaningful if
>> > you can't
>> > represent a fractional value.
>> can you give examples for that. which basic operations make sense with
>> int but not with complex<int>?
> It's the reverse. There is a number of mathematical operations available
> on complex that doesn't make sense with int.
> pow, cos, sin, sqrt, tan, polar, ...
> sin and cos returns a result in the -1..1 range. An integer can only
> store, -1,0,1 which obvisoulsy means you can only process the angles 0,
> 90, 180, 270.
This argument is simply not valid. The operation is no less meaningful
than using pow, cos, sin, sqrt, tan, etc. on an int. It may be the
case that there is no practical use for complex<int>, but that does not
mean the operations themselves are less meaningful.
> A complex number is by mathematical definition a superset of a floating
> point number, containing a real and an imaginary part (each a floating
> point number) so obviously you can't use two integers.
A common mathematical definition of a complex number is an ordered pair
of real numbers. But like int, float cannot represent all real numbers.
-- Jeremy Maitin-Shepard
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk