Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8624303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:29:39+00:00 2026-06-12T07:29:39+00:00

When you run a VBA macro that performs numeric calculations which result in a

  • 0

When you run a VBA macro that performs numeric calculations which result in a decimal value, the result that is returned may be incorrect.

Here are a couple of examples:

Dim me_wrong as Double
me_wrong = 1000 - 999.59

RESULT = 0.409999999999968

Dim me_wrong_too as Double
me_wrong_too = 301.84 - 301

RESULT = 0.839999999999975

I have never ever noticed this before. What on earth is going on???

I have seen the following article about Office 97 but can’t find anything about a bug in Excel 2007:
http://support.microsoft.com/default.aspx?scid=kb;en-us;165373

Plus it doesn’t explain why I have never seen it before.

Please help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:29:40+00:00Added an answer on June 12, 2026 at 7:29 am

    The explanation for the problem from Office 97 and VBA is equally applicable going forward into Excel 2007. The core VBA system is largely unchanged despite the migration into later versions, hence the same kinds of accuracy gremlins that plague older VBA macros will persist.

    The fundamental problem lies with the inherent inaccuracy in the representation of fractional numbers in binary, and how at least some effort to mitigate that inaccuracy was made with IEEE floating point representations. There is a very decent treatment of the subject of IEEE representation at this location.

    *Edit: Just a minor bit of extra info for detail. *

    For a very simple example that illustrates this issue in a trivial case, consider a situation in which decimals are represented as sums of inverse powers of two, eg 2-1, 2-2, 2-3, and so on. That ends up looking like .5, .25, .125, and so on. If you’re representing exactly those numbers, all is good. However, consider a number like .761; 2-1+2-2 gets you to .750, but now you need .011. 2-3 (.125) is too big, but 2-4 (.0625) is too small…so you keep going to smaller powers of two, realizing you’ll never quite represent the number precisely.

    The choice becomes where you stop resolving and accept the inherent inaccuracy as being “good enough” for the problem you’re solving/modeling.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a relative VBA novice, and designing a fairly complex macro that can run
I need to write a macro in VBA that will open every file in
Okay, i've got an Outlook 2003 VBA macro that clears a mail item's categories,
I have an Excel VBA macro that creates a folder tree based on an
I'm writing a VBA macro in Excel that analyzes data from the spreadsheet and
Has anyone had any luck with a vba macro that would convert this input:
I've a problem with this VBA macro. Sub demoChangeText() Application.Range(B2).Value = Overidden text End
I have a VBA macro that uses Microsoft MapPoint to calculate the distance between
I wrote a macro in VBA that does an action on some of the
I have an Excel file that has a bunch of VBA and macro code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.