comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Commutativity of multiplication
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Commutativity of multiplication [message #50968 is a reply to message #50961] Thu, 26 October 2006 01:26 Go to previous messageGo to previous message
Foldy Lajos is currently offline  Foldy Lajos
Messages: 268
Registered: October 2001
Senior Member
On Wed, 25 Oct 2006, JD Smith wrote:

> Commutation hasn't been broken, only "type commutation", which doesn't
> really exist. For all purposes, given the limitations of integer
> representation in computers, -500 and 4294966796 *are* the same. I
> could just as easily claim that "adding and subtracting 1 is broken":
>
> IDL> print, 4294967295UL + 1UL
> 0
>
> IDL> print,0b - 1b
> 255
>
> JD
>

If multiplication is commutative, then a*b should be equal to b*a.

IDL> a=-1l
IDL> b= 1ul
IDL> print, a*b eq b*a
1

Fine. If a*b is equal to b*a, then 1.0*(a*b) should be equal to 1.0*(b*a),
too.

IDL> print, 1.0*(a*b) eq 1.0*(b*a)
0

I tend to say that IDL's multiplication is not commutative in
the mathematical sense.

Other languages, like C are "more commutative":

signed int a=-1;
unsigned int b= 1;

printf("%d %d\n", a*b==b*a, 1.0*(a*b)==1.0*(b*a));

prints 1 1 (the result is signed int both for a*b and b*a).

regards,
lajos
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Syntax errors
Next Topic: Re: !P.SYMSIZE still broken? after 5 years?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 22:54:12 PDT 2025

Total time taken to generate the page: 0.88541 seconds