Slashdot Mirror


Excel 2007 Multiplication Bug

tibbar66 writes with news of a serious multiplication bug in Excel 2007, which has been reported to the company. The example that first came to light is =850*77.1 — which gives a result of 100,000 instead of the correct 65,535. It seems that any formula that should evaluate to 65,535 will act strangely. One poster in the forum noted these behaviors: "Suppose the formula is in A1. =A1+1 returns 100,001, which appears to show the formula is in fact 100,000... =A1*2 returns 131,070, as if A1 had 65,535 (which it should have been). =A1*1 keeps it at 100,000. =A1-1 returns 65,534. =A1/1 is still 100,000. =A1/2 returns 32767.5."

28 of 806 comments (clear)

  1. Yes. by oatworm · · Score: 3, Informative

    Yep - my office switched to Vista and Office 2007. Then again, we're a networking firm, so it's in our best interests to use stuff while it's still "beta" so we know the bugs and quirks before our customers start playing with it.

    As an aside, when I went to pick up a lease renewal form for my apartment complex, I noticed that the lady at the front counter was also running Office 2007, so I'd say it's out there - just not exceptionally widespread at the moment, compared to other versions of Office.

  2. Numerical Analysis of MS Excel by Anonymous Coward · · Score: 0, Informative

    Years ago I wrote a parser and interpreter for MS Excel. At that time, the numerical representation was not IEEE floating point, but a truncated, poor cousin (8 bit) of a decent float implemetation called "RK numbers". I recall that I needed to interpolate and provide semi-randomized numbers for the gaps in the number line that 8 bits (mantissa + ordinate) would incur.
    I wonder if MS still uses this implementation - which goes back to the early 1990s. It's a propietary, gappy implementation that was based, I think, on Mac / Motorola implementations.
    Just my cut on it - I may be off base.

    1. Re:Numerical Analysis of MS Excel by Mr2001 · · Score: 2, Informative

      RK numbers in Excel. They're not quite how you described them, though. It's a 32-bit value that can hold a 30-bit floating point number or a 30-bit integer (the last 2 bits are for the type), and if a number can't be represented either way, Excel will save it as a 64-bit IEEE float.

      --
      Visual IRC: Fast. Powerful. Free.
  3. Re:Dunno... by chrisb33 · · Score: 2, Informative

    The bug shows up for me. I'm running on Vista, and my About box gives the Excel version as 12.0.6024.5000 (MSO 12.0.6017.5000).

  4. Re:some limited testing by indaba · · Score: 3, Informative

    =(8500 * 1) * 7.71
    that evaluates to 65535

    but :
    =850*(771/10) evaluates to 100000

  5. Re:Dunno... by Quarters · · Score: 2, Informative

    Office 2K7 on XP SP2 and I see the same results as the article.

  6. Re:Dunno... by eck011219 · · Score: 1, Informative

    It's broken here -- WinXP SP2, MS Office 2007 (Excel v. 12.0.6024.5000).

    I've done a lot of defending of MS for Office 2007, but this is a little scary. Word can suck in spots, but math really has to work.

    --
    It is pitch black. You are likely to be eaten by a grue.
  7. Re:Oh no! by ozmanjusri · · Score: 5, Informative
    This is the most devastating bug in years.

    It could be for Excel users.

    65535 is common in computing because it's the highest number which can be represented by an unsigned 16 bit binary. If Excel is mishandling it somewhere in the background, chances are that failure will show up at multiple points.

    If I had an important Excel 2007 spreadsheet, I'd be loading it up in OOo Calc or an older version of Excel now.

    --
    "I've got more toys than Teruhisa Kitahara."
  8. Re:In OOXML? by AvitarX · · Score: 2, Informative

    I like Kivio (probably same complaints as Dia though)

    Has stencil sets available for cheap too.

    --
    Wow, sent an e-mail as suggested when clicking on "use classic" banner, and got a fast response that addressed my msg
  9. Re:In OOXML? by Anonymous Coward · · Score: 1, Informative
    Anyone know of a decent OSS replacement for Visio?

    I'm fond of Umbrello. But that replaces a completely different set of functionality from Visio.

  10. Not all formulas resulting in 65535 display wrong by JeffBean · · Score: 2, Informative

    A few observations:

    1) If you go into the Visual Basic editor and print the "Value" property of the cell containing the formula =850*771 you get 65535, as you should. The "Text" property however is "100000". So it seems the problem is not in the internal computation, but in the conversion to the displayed value.

    2) That said, I am not sure why, if you then enter =A1+1 into another cell you get 100001 instead of 65536. It seems the formula is picking up the displayed value, not the internal value when you perform addition, but not when you do multiplication.

    3) There is something special about the value 77.1. Other variations on the calculation produce the correct result.
    85 * 771 = 65535
    850 * 77.1 = 100000
    8500 * 7.71 = 65535

    I wrote a short C program so I could see what the actual floating point representations of these numbers were:

    #include
    #include

    int main (int argc, const char *argv[])
    {
            if (argc != 3)
            {
                  puts("You must enter two numbers");
            }
            else
            {
                  double v1 = atof(argv[1]);
                  double v2 = atof(argv[2]);
                  double result = v1 * v2;
                  printf("%f * %f = %f\n", v1, v2, result);
                  printf("%#016I64x * %#016I64x = %#016I64x\n", *(long long *)&v1, *(long long *)&v2, *(long long *)&result);
            }
            return 0;
    }

    This produced:
    850.000000 * 77.100000 = 65535.000000
    0x408a900000000000 * 0x4053466666666666 = 0x40efffdfffffffff

    Notice that the value 77.1 has a repeating fraction when represented in floating point. So does the result. In fact if you dig out your Intel manuals and decipher the hex representation of the result you find that it is the binary equivalent of 65534.99999999999999...

    It seems that the problem occurs in the conversion of that value to displayable text.

  11. Re:Looks like a typo by Firehed · · Score: 4, Informative

    Wouldn't that apply to 65,536, rather than 65,535? 65,535 is 0xFFFF, not 0x10000.

    --
    How are sites slashdotted when nobody reads TFAs?
  12. I have another theory entirely. by Mr+Z · · Score: 5, Informative

    ...except for the minor detail that 65535 is 0xFFFF... :-)

    That said, my 32-bit print routine for a 16-bit CPU actually works by printing two 16 bit numbers, with a slight hack to the 16-bit routine to allow it to print numbers in the range 65536 - 99999 for the lower 5 digits. It does this by dividing the 32-bit number by, you guessed it, 100000. It then prints the quotient and the remainder. It has to do some extra legwork, though, to get the leading zeros right across the two words, and I think it's there that the code went south if they're using a technique similar to mine.

    I'm guessing what happened here is that there's an off-by-1 error in a comparison somewhere (i.e. ">= 65535" instead of "> 65535"), and the 32-bit quotient/remainder print routine kicks in. Since the number is already smaller than 100000, it probably hits a fall-thru case where the quotient is assumed to be 1, and there's no remainder, hence it printing 100000.

    For reference, here's that assembly code I mentioned: prnum32.asm and prnum16.asm

    --Joe
    1. Re:I have another theory entirely. by imdx80 · · Score: 3, Informative

      Debug.Print Application.Cells(1, 1).Text
      Debug.Print Application.Cells(1, 1).Value

      where the formula is in cell A1. You get the correct & incorrect results depending on whether you look at value or text

  13. Re:In OOXML? by L'homme+de+Fromage · · Score: 2, Informative
    I hope you're not using octave for any combinatorial computations:

    octave:1> printf ("%20d\n",nchoosek(55,27))
        3824345300380179
    The correct answer is 3824345300380220, which R gives correctly:

    > options(digits = 20)
    > choose(55,27)
    [1] 3824345300380220
    Note that after a bunch of cancellations that 55!/(27!*28!) comes out to be

    53*47*43*41*37*34*31*29*11*7*5*2

    so the 5*2 at the end guarantees that the answer will end in a 0.
  14. Re:Google Spreadsheet bug by Mr+Z · · Score: 2, Informative

    Erp. I can't count. That IS a 52 bit number, and so is right on the edge of what a double precision mantissa can store. Move along.

  15. Re:Oblig. by jibjibjib · · Score: 2, Informative

    Actually it's quoted from Snow Crash.

  16. Not a bug by Anonymous Coward · · Score: 1, Informative

    By definition, 1 Hz = 1/s and 1 rad = 1. I follows that 1 Hz = 1 rad/s.

    The problem is of course in the semantics. There's nothing in the definition of a hertz that limits it to cycles or rotations. So Google's answer is among the infinity of possible interpretations. If an object turning at 1 rad/s beeps at every completed radian, the beep rate is 1 Hz.

    By the same vein, Google correctly reports that

        1 radian = 1.66053886 x 10^-24 moles

  17. Re:Pentiums by Anonymous+Freak · · Score: 2, Informative
    Yes, I know it's a joke.

    But, sadly, Office 2007 will not run on an FDIV Pentium. The fastest Pentium that had the FDIV bug was 100 MHz, which is far too slow to even attempt to install Windows XP on, which is a requirement for Office 2007. Way back when XP first came out, I got it to install on a Pentium MMX 233 MHz notebook with 64 MB of RAM, but Service Pack 2 made that computer impossibly slow. And it refused to install at all on an old Pentium 166 MHz computer I had lying around. (And it even had more memory.)

    --
    Another non-functioning site was "uncertainty.microsoft.com."
    The purpose of that site was not known.
  18. Re:Google Spreadsheet bug by Anonymous Coward · · Score: 1, Informative

    Ha fool - Octave is wrong!

    3824345300380220 is the answer. Go suck a tree.

  19. Re:Good Luck! by PeterBrett · · Score: 2, Informative

    Real engineers use the back of an envelope, a pencil and some rules of thumb.

  20. And yet it works FINE when you GRAPH it... by uptownguy · · Score: 5, Informative

    ....interesting twist...

    I just fired up Excel and created a simple graph:

    One column of numbers was a series from 845-855. The next column was the first column * 77.1. As expected, the series jumped from:

    65149.5, 65226.6, 65303.7, 65457.9, 100000, 65612.1, 65689.2, 65766.3...

    But then when I created a graph to display this, I had a simple straight line -- trying to plot the single data point represented by "100000" also displayed the accurate number. Any other calculations done with this number yielded the right result, too. Taking the value of the cell that displays100000 and multiplying it by 2 results in 131070.

    So all things considered, this really amounts to an Easter Egg. Most spreadsheets will calculate, graph, and function exactly as they should even using the results from a cell that displays inaccurately in that one case...

    --


    I would have to say that explosives are the most abused technology in all of history.
    1. Re:And yet it works FINE when you GRAPH it... by fruity_pebbles · · Score: 4, Informative

      That's true, but if you add 1 to that result you get 65537. And dividing either "1000000" or "100001" by 2 gives the correct results. I can replicate the problem as a display problem, but I can't produce any actual calculation errors.

  21. Re:Oh no! by Verte · · Score: 2, Informative

    Yes and no, the definition of a WORD has typically been hardware specific. For example, on a PDP, a word was 18 bits, IIRC. However, it has always meant a bit-field, which doesn't make any assumption about type.

    --
    We at slashdot are scientists, specialists and kernel hackers. Your FUD will be found out.
  22. Re:In OOXML? by Frankie70 · · Score: 4, Informative

    Welcome to the world of Floating point arithmetic.

    Look at these articles.

    http://support.microsoft.com/kb/q78113/
    http://c-faq.com/fp/printfprec.html
    http://c-faq.com/fp/fpequal.html

    Microsoft Excel was designed around the IEEE 754 specification with respect to storing and calculating floating-point numbers.

  23. Re:Microsoft just announced plans for their fix by FelixGordon · · Score: 4, Informative

    It looks more like the result of an overflow error at some stage of the calculation, since 65535 is the maximum value an unsigned 16 bit integer can hold.

  24. The reason it was named "Windows 95" by Solandri · · Score: 3, Informative

    For those who don't remember, the reason for the "95" name was likely because Windows "Chicago" kept getting delayed. Eventually Gates announced it was going to be released under the name "Windows 95". Speculation was that the name was chosen to pressure the development team to get it released in 1995 instead of letting it slip to 1996. They released it in late summer 1995, arguably too soon.

    1. Re:The reason it was named "Windows 95" by Shotgun · · Score: 2, Informative

      No. There was a push on to rename releases by year number. Microsoft's push to make the OS a service instead of a product. There was to be a release every year. Microsoft has been searching for a way to keep users buying the same product over and over for years, and this was just one iteration of that search.

      Some of the Microsoft pawned Ziff-Davis writers went on record touting this as the next big wave to save us all.

      --
      Aah, change is good. -- Rafiki
      Yeah, but it ain't easy. -- Simba