Reputation: 6671
I was just going through a question
So I tried to calculate it myself and check the result.. But the result always I get is a rounded value. Why ??
Actually I should get 0.1428......
@Everyone who answered: Thank you everyone, as per SO rules I can accept only one answer, so accepting the one who was earliest.
Upvotes: 2
Views: 94
Reputation: 3619
SELECT 2.0/14
Need to decimal place to "trigger" the floating point
Upvotes: 2
Reputation: 499382
You are doing integer division.
At least one of the operands needs to be a float/decimal in order for the whole expression to evaluate to one of those types.
Upvotes: 2
Reputation: 839234
The result of the integer division 2/14
is always 0.
Try 2.0/14.0
instead.
Upvotes: 2
Reputation: 204924
try that
select 2.0 / 14
If you use integers the result will be integer too. integers are not floating point numbers
Upvotes: 3