floating point calculation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Never

    floating point calculation

    I'm trying to perform a calculation on a field in SQL Server that
    should return a value with a decimal point. My problem is that the
    value returned is truncated without the decimal point. Is there a
    setting that needs to be turned on in SQL server to allow this?

    for example

    Select 20/3

    should return 6.6666667

    but instead I get 6
  • Greg D. Moore \(Strider\)

    #2
    Re: floating point calculation


    "Never" <nevermind@inam e.com> wrote in message
    news:e43b4225.0 405071534.9a29f 0a@posting.goog le.com...[color=blue]
    > I'm trying to perform a calculation on a field in SQL Server that
    > should return a value with a decimal point. My problem is that the
    > value returned is truncated without the decimal point. Is there a
    > setting that needs to be turned on in SQL server to allow this?
    >
    > for example
    >
    > Select 20/3
    >
    > should return 6.6666667[/color]

    No, you should get 6.

    Try select 20.0/3.0

    You'll get 6.666666

    When you say select 20/3 you're telling SQL Server you're starting with
    ints, so it converts the answer to an int.
    [color=blue]
    >
    > but instead I get 6[/color]


    Comment

    Working...