-1^2

31/07/2007 - 17:16 por Farnesio | Informe spam
It seems that in Excel the expression -1^2 is equal to 1 (or similar with
any expression having a minus sign before, and and exponent after; the minus
sign is included in the expression). It is different for instance in Visual
Basic 6.0 or 2005, where -1^2 = -1, or in the other programming languages I
remember. I presume it is also different in the Basic available into Excel
via Alt-F11. It looks like an inconsistency. ¿Is there any option in Excel to
modify this? Regards.

Preguntas similare

Leer las respuestas

#1 Xavier Budet Graco
31/07/2007 - 19:20 | Informe spam
Hola Farnesio, en Matemáticas -1^2 = -1 * -1 = 1.

Saludos,

Xavier

Quitar MAC para contestar. Gracias.

"Farnesio" escribió en el mensaje news:
It seems that in Excel the expression -1^2 is equal to 1 (or similar with
any expression having a minus sign before, and and exponent after; the minus
sign is included in the expression). It is different for instance in Visual
Basic 6.0 or 2005, where -1^2 = -1, or in the other programming languages I
remember. I presume it is also different in the Basic available into Excel
via Alt-F11. It looks like an inconsistency. ¿Is there any option in Excel to
modify this? Regards.
Respuesta Responder a este mensaje
#2 KL
31/07/2007 - 20:11 | Informe spam
Hi guys,

"Xavier Budet Graco" wrote in message
news:
Hola Farnesio, en Matemáticas -1^2 = -1 * -1 = 1.

"Farnesio" escribió en el mensaje
news:
It seems that in Excel the expression -1^2 is equal to 1 (or similar with
any expression having a minus sign before, and and exponent after; the
minus
sign is included in the expression). It is different for instance in
Visual
Basic 6.0 or 2005, where -1^2 = -1, or in the other programming languages
I
remember. I presume it is also different in the Basic available into Excel
via Alt-F11. It looks like an inconsistency. ¿Is there any option in Excel
to
modify this? Regards.



I guess there is an inconsistency, but it is not that elevating -1 in power
2 gives -1 in VBA, and 1 on a worksheet. Actually it is the *mathematical
operator precedence* consistency issue. In VBA -(minus) seems to have a
higher precedence over ^(power), while on an Excel worksheet it is
viceversa. Just try to execute the following instruction in the 'Immediate'
window of any VB Editor: ?(-1)^2

So, I believe Xavier is right :-)

Regards,
KL
Respuesta Responder a este mensaje
#3 KL
31/07/2007 - 20:15 | Informe spam
Sorry, too quick typing :-) Just a small correction.

"KL" wrote:
...In VBA -(minus) seems to have a higher precedence over ^(power), while
on an Excel worksheet it is viceversa.



Actually, I meant to say just the opposite:
...In VBA ^(power) seems to have a higher precedence over -(minus), while on
an Excel worksheet it is viceversa.

Regards,
KL
Respuesta Responder a este mensaje
#4 Héctor Miguel
31/07/2007 - 20:53 | Informe spam
hi, guys !

I'm pretty sure Xavier is right, given that excel & maths *shares* expressions [and operator precedences ?]

what is a litte confusing [to me] is that OP reffers to *other languages he remembers* -?- [i.e.]

VBA5 [excel 97]
? -1^2
-2

WS: =-1^2 = 1

VBA6 [excel 2k and above]
? -1^2
-1

WS: =-1^2 = 1
[the same in all versions]:

greetings,
hector.

__ previous posts __
Farnesio wrote in message ...
It seems that in Excel the expression -1^2 is equal to 1 (or similar with any expression having a minus sign before
and and exponent after; the minus sign is included in the expression).
It is different for instance in Visual Basic 6.0 or 2005, where -1^2 = -1, or in the other programming languages I remember.
I presume it is also different in the Basic available into Excel via Alt-F11. It looks like an inconsistency.
Is there any option in Excel to modify this? Regards.


Xavier Budet Graco wrote in message ...
Hola Farnesio, en Matemà¡ticas -1^2 = -1 * -1 = 1.

KL wrote in message ...
Hi guys,
I guess there is an inconsistency, but it is not that elevating -1 in power 2 gives -1 in VBA
and 1 on a worksheet. Actually it is the *mathematical operator precedence* consistency issue.
In VBA -(minus) seems to have a higher precedence over ^(power), while on an Excel worksheet it is viceversa.
Just try to execute the following instruction in the 'Immediate' window of any VB Editor: ?(-1)^2

So, I believe Xavier is right :-)

Regards,
KL
Respuesta Responder a este mensaje
#5 Farnesio
01/08/2007 - 09:48 | Informe spam
Debo estar acostumbrado a lenguajes de programación 'tradicionales' (empecé
con Fortran y creo recordar que en Pascal, PL/I o en todos los Basic era
igual), pero -a^b para mí intuitivamente es -(a^b), por lo del orden de
preferencia (primero la potencia, luego sumas o restas). De hecho, esta
diferencia en Excel la he notado comprobando en Excel unos resultados
parciales de un programa que había desarrollado en VB.NET donde aparecía una
curva normal tipificada (con una expresión e ^ -x2/2, donde este exponente
pretende evidentemente ser negativo). Al hacer un gráfico en Excel me
aparecía la curva ¡boca abajo!.

No es nada que no se pueda arreglar poniendo unos paréntesis, claro, y de
hecho me da igual qué criterio se use, pero hombre, que sea siempre el mismo,
p.f., porque que Excel y Visual Basic no tengan el mismo, es una buena fuente
de errores.


"Héctor Miguel" wrote:

hi, guys !

I'm pretty sure Xavier is right, given that excel & maths *shares* expressions [and operator precedences ?]

what is a litte confusing [to me] is that OP reffers to *other languages he remembers* -?- [i.e.]

VBA5 [excel 97]
? -1^2
-2

WS: =-1^2 = 1

VBA6 [excel 2k and above]
? -1^2
-1

WS: =-1^2 = 1
[the same in all versions]:

greetings,
hector.

__ previous posts __
> Farnesio wrote in message ...
> It seems that in Excel the expression -1^2 is equal to 1 (or similar with any expression having a minus sign before
> and and exponent after; the minus sign is included in the expression).
> It is different for instance in Visual Basic 6.0 or 2005, where -1^2 = -1, or in the other programming languages I remember.
> I presume it is also different in the Basic available into Excel via Alt-F11. It looks like an inconsistency.
> Is there any option in Excel to modify this? Regards.


>> Xavier Budet Graco wrote in message ...
>> Hola Farnesio, en Matemà¡ticas -1^2 = -1 * -1 = 1.

>>> KL wrote in message ...
>>> Hi guys,
>>> I guess there is an inconsistency, but it is not that elevating -1 in power 2 gives -1 in VBA
>>> and 1 on a worksheet. Actually it is the *mathematical operator precedence* consistency issue.
>>> In VBA -(minus) seems to have a higher precedence over ^(power), while on an Excel worksheet it is viceversa.
>>> Just try to execute the following instruction in the 'Immediate' window of any VB Editor: ?(-1)^2
>>>
>>> So, I believe Xavier is right :-)
>>>
>>> Regards,
>>> KL



email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida