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:

  • How to send multiple emails from sql server database using sp_send_dbmail procedure
  • Embedded SQL Count is taking too much to proceed
  • Selecting column names from a query NOT a view
  • Getting error on nested query
  • SQL IN Statement splitting parameter
  • How do I update a XML string in an ntext column in SQL Server?
        PRINT cast (0.99986333333333333333333333333333333333 * 9999.99 as decimal (38, 30));

    I get the result:


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


    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?



    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:

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

    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.