Thread: make the results to two decimal places

  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    1

    make the results to two decimal places

    First of all (some background) - I know nothing about programming in anything except VB for Applications in Excel and a little SQL.

    21 months ago my employer insisted in purchasing custom software I specified from a Chinese company with limited English skills. Today there is no end in sight. (Additionally, I am not certain he is using C++, but I believe it is a C language.) Last conference call w/screen sharing he opened his code and I was able to read it enough to find some errors in his calculations.

    I have questioned him why on every calculation he multiplies by .01 and then multiplies by 100. His answer to this question was "multiply by *.01 then multiply by *100 is to make the results to two decimal places". Which seems absurd to me.

    Sample code:
    Code:
    @MinPer=(select top 1 cast(MinPer as numeric(9,2))*0.01/(case when UOM='sec' then 60 else 1 end)*100 
    Doesn't the 2 in numeric(9,2) mean truncate to two decimal places?

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    >> Doesn't the 2 in numeric(9,2) mean truncate to two decimal places?
    Something like that it seems: decimal and numeric (Transact-SQL)

    >> Which seems absurd to me.
    Seems that way to me too. In an expression using decimal data types, dividing by 100 then multiplying by 100 neither truncates nor rounds.

    I'm no SQL guru, but it seems to have similar data type precedence rules as C: Data Type Precedence (Transact-SQL)

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Decimal places
    By Gordon in forum Windows Programming
    Replies: 9
    Last Post: 06-08-2008, 09:04 AM
  2. Decimal places
    By Gordon in forum Windows Programming
    Replies: 4
    Last Post: 09-28-2007, 10:03 AM
  3. Is there a way to round to 2 decimal places?
    By osiris^ in forum C Programming
    Replies: 10
    Last Post: 07-27-2007, 02:08 PM
  4. Getting Two Decimal Places
    By LostNotFound in forum C++ Programming
    Replies: 1
    Last Post: 03-29-2003, 08:34 PM
  5. decimal places
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 08-01-2002, 07:08 PM