Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Negative Zero?

2 views
Skip to first unread message

Jerry W. Lewis

unread,
Dec 5, 2002, 7:30:44 AM12/5/02
to
=test(0) returns a value of -0, for which =(test(0)=0) is False. Any
ideas on what is going on?

Function test(a)
test = -a
End Function

Jerry

Bob Phillips

unread,
Dec 5, 2002, 7:44:19 AM12/5/02
to
Jerry,

I think it is because you have not declared your function type, so it assume
variant

Try this and it works as you would expect

Function test(a) As Long


test = -a
End Function

--
HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"Jerry W. Lewis" <post_a_reply@no_e-mail.com> wrote in message
news:3DEF479F.4020003@no_e-mail.com...

J.E. McGimpsey

unread,
Dec 5, 2002, 8:15:19 AM12/5/02
to
FWIW, in XLv.X, =(test(0)=0) returns TRUE.

In article <3DEF479F.4020003@no_e-mail.com>, Jerry W. Lewis

Jerry W. Lewis

unread,
Dec 5, 2002, 10:18:25 PM12/5/02
to
Long is an integer my application is not

Function test(a As Double) As Double


test = -a
End Function

still returns -0. The Locals window shows the value to be 0 just before
return. I have only been able to produce -0 when the worksheet
interacts with VBA. Strictly within a worksheet or strictly within VBA
it does not seem possible.

Jerry

Jerry W. Lewis

unread,
Dec 5, 2002, 10:21:50 PM12/5/02
to
XLv.X?

in an Excel (97, 2000, or XP) worksheet =(test(0)<0) returns True, and
=(test(0)=0) returns False.

Jerry

J.E. McGimpsey

unread,
Dec 5, 2002, 10:48:34 PM12/5/02
to
In article <3DF0187A.7070109@no_e-mail.com>, Jerry W. Lewis
<post_a_reply@no_e-mail.com> wrote:

> XLv.X?

XL v.X for Macintosh

Dave Peterson

unread,
Dec 5, 2002, 10:49:04 PM12/5/02
to
Function test(a)
test = 0 - a
End Function

Worked ok for me (xl2002). Something about the unary operator??

There's been a few discussions about this kind of stuff. I searched google and
found a partial thread that you may want to look at. (not sure if it'll help,
but you may find it, er, exasperating.)

http://groups.google.com/groups?threadm=d2c023b0.0204021139.48592e1e%40posting.google.com
(one line in your browser)

--

Dave Peterson
ec3...@msn.com

0 new messages