exponentiation operator (lack of)

J

jacob navia

Richard Bos a écrit :
Get a clue. You are not an Ada advocate; you are therefore not supposed
to be this stupid.

Richard

This is OFF TOPIC.

If anything is OFF TOPIC here, insults are.
Please let's keep manners.

You disagree with Mark?

Tell him so, but do it without insults, or attacks.

Thanks in advance for your understanding.

jacob
 
M

Mark McIntyre

Read a history book... :)

Get a clue. You are not an Ada advocate; you are therefore not supposed
to be this stupid.[/QUOTE]

No idea if thats addressed at me or Carlos, but either way, C was
written to be a higher level language than the assembler that Thompson
et al were otherwise forced to use on the PDP-7, yet compact and
simple enough to fit into the very limited memory available. The
original language was deliberately close to the machine, using
concrete data types and operators which existed on the target h/w.
Mark McIntyre
 
?

=?iso-8859-1?q?Dag-Erling_Sm=F8rgrav?=

Giving this ongoing enlargement in the scope of C applications,
I see no reason why a new operator (** or ^^) could not be
introduced to meet those needs either in a future standard, or
in a "successor to C" , as discussed in another thread.

Alright, it's quiz time. Consider the following program:

#include <stdio.h>

int main(void)
{
int a = 2, b = 3;
int *bp = &b;

printf("%d\n", a**bp);
return 0;
}

1) what is the effect of the above code?

2) explain the relationship between the & and && operators

3) explain the relationship between the ^ and ^^ operators

4) explain the relationship between the | and || operators

5) which of the above is a trick question?

DES
 
K

Keith Thompson

Alright, it's quiz time. Consider the following program:

#include <stdio.h>

int main(void)
{
int a = 2, b = 3;
int *bp = &b;

printf("%d\n", a**bp);
return 0;
}

1) what is the effect of the above code?
2) explain the relationship between the & and && operators
3) explain the relationship between the ^ and ^^ operators
4) explain the relationship between the | and || operators
5) which of the above is a trick question?

I think that the first person to implement the short-circuit xor
operator will become nearly as rich as the first person to invent a
way to factor large primes.

(My own "exclusive-and" operator (A and B but not both) is a small
step in this direction.)
 
E

Eric Sosman

Dag-Erling Smørgrav said:
Alright, it's quiz time. Consider the following program:

#include <stdio.h>

int main(void)
{
int a = 2, b = 3;
int *bp = &b;

printf("%d\n", a**bp);
return 0;
}

1) what is the effect of the above code?

If compiled and executed by a C implementation
conforming to any version of the Standard, as amended,
it attempts to write the digit '6' and a newline '\n'
to the standard output stream. Whether this attempt
succeeds or not, it then attempts to close all open
streams (including the standard output) and returns an
implementation-defined "success" indication to the
environment.
2) explain the relationship between the & and && operators

They are both C operators.
3) explain the relationship between the ^ and ^^ operators

One is a C operator, one is not. They are related
by their antipathy, like Don Carlo and Don Alvaro.
4) explain the relationship between the | and || operators

They are both C operators.
5) which of the above is a trick question?

Number 5.
 
M

Michael Wojcik

I think that the first person to implement the short-circuit xor
operator will become nearly as rich as the first person to invent a
way to factor large primes.

Obviously, the logical-xor operator short-circuits when the result
is neither true nor false.

On a more serious note, short-circuiting is obviously not the
only characteristic which distinguishes the bitwise and logical
operators (| versus || and & versus &&), so while a "logical xor"
wouldn't short-circuit, it would still be distinct from bitwise
xor, and could have its own operator. There just isn't any call
for it.
 
M

Markus Becker

Chris Torek said:
size_t size;
size = sizeof(i);

compiles to a simple assignment, despite "sizeof(i)"'s resemblance
to a call to a function.

Some people seem to have too much parentheses. I'm sure you
know that, but just for the record: 'sizeof' is an operator,
not a function and therefore it's not especially astonishing
that it does not generate a function call.

int i;
i = -(1);

won't generate one either.

Markus
 
D

Dave Thompson

It, I think, is worth noting that APL -- a language designed by a
mathematician -- avoids the whole operator binding ("precedence
and associativity") problem by defining it away. Operators are
handled strictly in textual order, right to left. For instance,

* 3 + 4 (iota) 7

is handled as:

iota 7: produces the vector 1 2 3 4 5 6 7
+ 4 [vector]: produces the vector 5 6 7 8 9 10 11
* 3 [vector]: produces the vector 15 18 21 24 27 30 33
Almost. APL is written infix (for this example 3 x 4 + iota 7)
but with no precedence (or equivalently all the same precedence) for
dyadic and right associative so they execute right-to-left except if
overridden by parentheses; and prefix are inherently right to left
(and unambiguously parsed), and there are no postfix.

For additional confusion APL follows mathematical terminology in
calling things like + and x that operate on data 'functions' and using
'operators' for things that operate _on functions_ e.g. slash for
reduce in 'plus slash times' for dot-product. C has no direct analog
builtin of such, and C++ only a pale imitation in bind1st etc.,
although in both you can write functions that take a pointer to
function and do something with it e.g. find_zero_of (func_ptr_t).

- David.Thompson1 at worldnet.att.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top