Question

I was using Microsoft SQL Query Analyzer the other day and wrote a very simple select statement:

SELECT 22/7 as [PI Equiv]

I was suprized that the result was 3, when I was expecting to see 3.1428571. Even if you declare the output to be Numeric(18,7), you still get 3.0000000.

DECLARE @Answer Numeric(18,7)
SET @Answer = 22/7
SELECT @Answer as [PI Equiv]

RESULT = 3.0000000

What other languages return integer values when the dividend and divisor are both integers?

No correct solution

Licensed under: CC-BY-SA with attribution
scroll top