Share via

Access VBA ^ operator error

Anonymous
2013-10-03T02:37:56+00:00

There seems to eb an error in Access VBA "to the power" operator (^) when the exponent is negative.

a^-b == 1/(a^b) but access gets this wrong (except for special cases, when a is a power of 2 for example)

For example the following into the imediate pane:

?1/(3^-1)

And you get

2.9837982704509 instead of the correct answer of 3.

I have tried various versions of this test (explicitly declaring datatype to be double for example) and I get the same result.  Excel performs exactly the same calculation correctly (so DOES return 3 in the above example)

Has anyone else observed this error?

Is this bug scheduled to be fixed?

Thank you

Colin

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

4 answers

Sort by: Most helpful
  1. Anonymous
    2013-10-09T05:40:06+00:00

    Hi Jeeped,

    Are you able to recreate this problem after opening a query in pivot table view?

    I can recreate it on a number of machines here in different databases and so I am keen to know if you can see this too?

    Is there anyone else out here who can also try this and see if they have the problem?  (It only happens after the PT query)

    many thanks

    Colin

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2013-10-03T07:05:08+00:00

    Even more strange...

    I close access and then re-open it.  I do the maths in the immediate window ( ?1/(3^-1) ) and get the right answer.

    I then open a regular query that I have in access - just a simple "select query" designed in the QBE (?)grid as usual.  Just 700 rows of data.  I view it as a pivot table.

    I go back to the immediate window and execute the command - now I get the wrong answer (2.9837982704509)

    Even if I now close the PT/query i continue to get the wrong answer to my maths, until I sut down access.

    Very concerning...  Some kind of memory overflow?

    Please help...

    Colin

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2013-10-03T05:02:50+00:00

    Hi Jeeped,

    That is even stranger!.  I promise I am not making this up - here is a screen shot of my imediate window.

    I am running Office Professional Plus 2010, Access version 14.0.6129.5000 (32-bit)

    Does anyone else have this problem?

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2013-10-03T03:55:32+00:00

    I'm not sure how you are achieving a result of 2.9837982704509. My own Access 2010 with Office SP2 returns 3 as expected using the Immediate window (Alt+F11, Ctrl+G)

    Was this answer helpful?

    0 comments No comments