SQL Server returning a different result to a physical calculator with decimal numbers

So as part of a query I am running i need absolute accuracy (or as close as possible with computers) for the result.

When i plug this equation into SQL Server and run it:

  • stored procedure with isnull(expression, replacement) return nothing
  • Visual Studio Opens but wont load SSIS package with devenv
  • Compress rows with nulls and duplicates into single rows
  • How do I assign weights to different columns in a full text search?
  • LINQ to SQL ToList() is creating duplicates and dropping entries
  • How to properly connect to database in vb
  • BEGIN
        PRINT cast (0.99986333333333333333333333333333333333 * 9999.99 as decimal (38, 30));
    END;
    

    I get the result:

    9998.623334700000000000000000000000
    

    However when I plug these numbers into my physical calculator I get the result:

    9998.623335
    

    What i need to know is which one is right and why?

    The SQL Server answer is the one Google Calculator produces and another online calculator advertised for extreme accuracy.

    Can anyone show to me/ prove to me which one i should use?

    Cheers

    Joe

    One Solution collect form web for “SQL Server returning a different result to a physical calculator with decimal numbers”

    I think you’ve answered your own question by stating that two other sources back up SQL Server on this.

    Further, if you cast each operand, so you get exact (not floating point) math, you get the same answer:

    BEGIN
        PRINT CAST(CAST(0.99986333333333333333333333333333333333 AS decimal(38,30)) * CAST(9999.99 AS decimal(38,30)) as decimal (38, 30));
    END;
    

    So I’d trust the SQL Server answer.

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.