Storing decimal values

We (like many organizations) are having rounding issues. I'm currently building out a warehouse for an organization and thought it would be fine to just set decimal columns to float. I'm working with some test data and loaded .02 into a table. When I did
a select on the table the value came back as:
.0199999995529652
What? I mean that's effectively .02 but why not just store .02!?
Is there a best practice data type I should be using to store decimal values?

Money is what is causing the problems. Two decimal places isn't precise enough. I want to minimize the rounding problem by rounding only in one place; at the client.
Money stores 4 decimal places.
money and smallmoney (Transact-SQL)
Hasn't be a problem for me in Datawarehouse-Projects.
But of course it depends on how often you re-calculate against it, whether this is sufficient.
Andreas Wolter | Microsoft Certified Master SQL Server
Blog: www.insidesql.org/blogs/andreaswolter
Web: www.andreas-wolter.com |
www.SarpedonQualityLab.com

Similar Messages

  • How to display BAPI decimal values into webdynpro!

    Hi All,
    I have a problem to display decimal values from R/3 system to webdynpro table.
    Iam using structure there declared all the varaibles as decimal 15,2 .
    But I am not able to disply the decimal values intable  of webDynpro.
    Please help me for this.
    Thanks in advance.
    BHI

    Hi,
        as u r importing RFC model all the datatypes in java side  corresponding to r/3 are also created .
    see in the dictonary of ur project .simple and structure type are created and u can use it.
    and u r storing the  data in some model node so when u r using table control rightclick on table and select structure binding it will display the context in ur view and from there u can select the attributes u want to display.
    if u r copying data of modelnode to value node u can also select structure binding option in wizard which set the datatype for the attributes .
    thanks,
    yashpal

  • Decimal values in SP15

    Hi,
    we're on SP15 and try to save decimal values like 15000,34) with the help of a bapi.
    When we save 15000,00 everything works fine.
    When we try to save 15000,23, the bapi only receives 0,00 and thus 0 is stored.
    The Input field in VC is of type "number" as well as the input field of the bapi.
    Who knows how to forma the input field in visual composer?
    Thanks a lot and kind Regards,
      Benni

    Hi ,
    Sorry Here my server is not wrkg . can please check on properties of inputfield. there u can find ceil or round Function u can Restirct the Number values .
    Note :
    1) Here u want to display only exact amount like 1000 or With decimals 1000.00 .
    2)can u elaborate ur question brief so tht i can some idea.
    Regard s,
    venkat

  • How do I convert an alpha character from a text string to its decimal value

    I am trying to find out the actual decimal value of a character in a string. So far the code below is as far as I got. I am able to get what I guess is a byte value.
    This is for a school assignment:
    The idea behind what I am trying to do is to design a hash function to store dictionary words into a bucket array hash table, without using the existing Hashtable.class
    so far this is what I can come up with to get some kind of value for each character in the string, however, what I am trying to get is the decimal value for each character.
    public static void main(String args[]){
         String word = "abcdefghijklmnopqrstuvwxyz";
         for (int i=0 ; i < word.length(); i++){
         System.out.print((word.substring(i,i+1)));
         System.out.print("\t : "+((word.substring(i,i+1))).getBytes());
    Thankyou for any replies.

    I'm not sure I completly understand your goal- what you mean by "decimal value", but, if you simply want to find the byte value of each character in a String, you would probably be better off using getBytes() in a way like this,
    byte [] bytes = string.getBytes();
    Then, if you need to map that to a charcter, you could use a for loop like
    for (int x = 0; x < bytes.length; x++) {
    table.put((char)bytes[x], bytes[x]);
    which assummes this bucket class of yours allows primitive data types like so (in Hashtable or HashMap, you would have to use a wrapper Object). I guess, my point reduces to, don't use substring and string search methods (like indexOf()), unless you have to because they are more expensive then just maping the array of bytes and chars, which seems to be what you are interested in doing.

  • Decimal  values for a field in ALV

    Hi,
    I created an ALV report.
    It has a field which will display the calculated value as '103,839,389'. This should be dispalyed as '103,839,389.00' with decimal value, I mean with 2 decimal places, how can this be achieved?
    Thanks,
    Kumar

    hi check this..
    use these in populating the fieldcat..
    it_fieldcat-decimalsfieldname = fieldname
    it_fieldcat-decimalstabname   = tabname
    it_fieldcat- decimals_out   = 2.
    regards,
    venkat

  • ALV report - remove of decimal values

    Hi experts,
    In my ALV report, output table having decimal values, ex:90000.50, i want to display only 90000,
    can help any one inthis.
    Thanks in advance.
    Regards
    Rams

    Hi,
    for that particular field in Field catalog..
    <ur field cat>-decimals_out = 0.
    see this sample code.
    type-pools: slis.
    DATA: begin of itab6 occurs 0,
    chk type c,
    a type p decimals 2,
    b type p decimals 2,
    c type c,
    end of itab6.
    data: ls_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
    wa_layout TYPE slis_layout_alv.
    itab6-a = '1.12'.
    itab6-b = '2.25'.
    itab6-c = '+'.
    append itab6.
    append itab6.
    append itab6.
    append itab6.
    ls_fieldcat-fieldname = 'A'.
    ls_fieldcat-seltext_m = 'A'.
    append ls_fieldcat.
    ls_fieldcat-fieldname = 'B'.
    ls_fieldcat-seltext_m = 'B'.
    ls_fieldcat-decimals_out = 0.  "this ll do
    append ls_fieldcat.
    ls_fieldcat-fieldname = 'C'.
    ls_fieldcat-seltext_m = 'C'.
    append ls_fieldcat.
    wa_layout-box_tabname = 'ITAB6'.
    wa_layout-box_fieldname = 'CHK'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = sy-repid
    it_fieldcat = ls_fieldcat[]
    IS_LAYOUT = wa_layout
    TABLES
    t_outtab = itab6[].
    Cheers,
    jose.

  • How to convert a number to FLOAT with 9 decimal values.

    Hi all,
    I need to convert a number like '10.02' to a floating point number with 9 decimal values like '10.022111221'. I think that the right function is TO_BINARY_FLOAT, but how can I obtain 9 decimal values? If I use the following syntax:
    select TO_BINARY_FLOAT(num) from table
    I obtain a floating point values with a variable number of decimal numbers after the ".", instead I need 9 number after ".".
    Regards,
    Maurizio.

    Hi,
    the number I need to select is the result of a product, for example:
    select (Num_A * Num_B) from Table;
    Num_A has 2 decimal numbers, like 12.01 and Num_B could be: 12.111111111.
    Now, Num_A * Num_B = 653.999999994
    but I issue:
    select TO_BINARY_FLOAT(54.00 * 12.111111111) from Table
    I obtain:
    654, a rounded value, but I need 653.999999994.

  • Rounding off to a variable value to 4 decimal values in sap script ouput

    Hi All,
    I have a value getting displayed in sap script output as 235.6789 i want to Round off this variable value to 4 decimal values!
    What is the formatting option need to be used & how!
    Thanks in advance.
    Thanks,
    Deep.

    Hi,
    1.In layout just call that variable, where you need like:
    &variable(.4)&.
    Just see these:
    &symbol(Z)&  Omit Leading Zeros 
    &symbol(S)&  Omit Leading Sign 
    &symbol(<)&  Display Leading Sign to the Left 
    &symbol(>)&  Display Leading Sign to the Right 
    &symbol(C)&  Compress Spaces 
    &symbol(.N)&  Display upto N decimal places 
    &symbol(T)&  Omit thousands separator 
    &symbol(R)&  Right justified 
    &symbol(I)&  Suppress output of the initial value
    Regards,
    If helpful reward with points(Don't forget).

  • Loading decimal  value to an infoobject of type char

    I have an extract structure with field timestamp, which is of type dec and length 15. Now i want to load this value to an infoobject in ODS. But this infoobject is of type char and length 18. when infopackage loading is scheduled it is giving the following error. Record 1 :InfoObject /BIC/IFITMSTMP does not contain alpa-conforming value 20061206084944.
    Is it because i tried to move a dec valu into a char field with a different length? If so  how will i load a decimal value of length 15 to a char of length 18. Can anyone please help me with this?
    Thanks in advance.

    if u r using BI7.0
    go to the datasource of the cube
    in the general info tab of the datasource
    there is a check box with PSA not typed
    check it
    if u check it all the values from the external source will be converted into character format irrespective of their data type

  • Loading a decimal value to an infoobject of type char

    I have an extract structure with field timestamp, which is of type dec and length 15. Now i want to load this value to an infoobject in ODS. But this infoobject is of type char and length 18. when infopackage loading is scheduled it is giving the following error. Record 1 :InfoObject /BIC/IFITMSTMP does not contain alpa-conforming value 20061206084944.
    Is it because i tried to move a dec valu into a char field with a different length? If so  how will i load a decimal value of length 15 to a char of length 18. Can anyone please help me with this?
    Thanks in advance.

    if u r using BI7.0
    go to the datasource of the cube
    in the general info tab of the datasource
    there is a check box with PSA not typed
    check it
    if u check it all the values from the external source will be converted into character format irrespective of their data type

  • Decimal values are not flowing to Excise Invoice created in J1IIN

    Dear Sap Gurus,
    Please help me with the problem. After creation of invoice in VF01 when i am creaing outgoing excise invoice decimal values for BED, ECS and SEC. ECess( AT1) are not coming instead values are rounded of to nearest whole number.
    for ex.
    if invoice values are as below
    BED= 16
    ECS= 3.2
    HSC= 1.6
    when excise iinvoice is created values are changes as below
    BED= 16
    ECS= 3
    HSC= 2
    please give propeer solution
    reg.
    suresh

    Check in Logistics - General -> Tax on Goods Movements -> India -> Basic Settings -> Maintain Company Code Settings. 
    Also ensure that in V/06, for the respective excise condition types, rounding is not activated.
    thanks
    G. Lakshmipathi

  • Error saving purchase order data decimal values in SAP R/3

    sir,
    PO was created with currency japanese YEN using Tcode ME21N . The net price was showing 142502300 (in JPY).
    when checked in EKPO table , it saved with a value 1425023.00  instead of  142502300 . 
    what can be done to correct this.      
    In PO Print out , it showing values as 1425023.00  which is wrong.
    SPRO>> NET WEAVER >> GENERAL SETTINGS >> CURRENCY>> SET DECIMAL values FOR CURRENCY CODES is showing 0 decimals against JPY (Japanese YEN)
    I want to know where else the Decimal values could have been set to 2 decimal places.
    FOr other currencies like US Dollars  there is no error.
    Regards,
    Srinivasa Murthy

    Hello Srinivasa
    Please check the forum Rules of Engagement - https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement.
    Cross posting is not permitted. This issue is already raised in the application area forum which is probably correct. This does not look like a PI technical issue.
    Regards
    Mark Smyth
    XI/PI Moderator

  • How to load decimal values into a file using bcp in SQL Server 2000?

    Hi everyone,
    I'm trying to load data from a database table to a text file using bcp on SQL Server 2000. When I'm loading the decimal values, the values before the decimal are not being loaded into the file. How could I load the values before decimals?
    Here are the DDLs and DMLs of what I'm trying to run:
    CREATE TABLE [dbo].[Product_Sales](
    [Year_of_Sale] [smallint] NOT NULL,
    [Product_Type] [varchar](25) NOT NULL,
    [Product_Group] [varchar](25) NOT NULL,
    [Category_Type] [varchar](25) NOT NULL,
    [Category_Group] [varchar](10) NOT NULL,
    [Product_Count] [bigint] NOT NULL,
    [Product_Amount] [decimal](19, 2) NOT NULL,
    [Category_Count] [bigint] NOT NULL,
    [Category_Amount] [decimal](19, 2) NOT NULL,
    CONSTRAINT [PK_Product_Sales] PRIMARY KEY CLUSTERED
    [Year_of_Sale] ASC,
    [Product_Type] ASC,
    [Product_Group] ASC,
    [Category_Type] ASC,
    [Category_Group] ASC
    ) ON [PRIMARY]
    ) ON [PRIMARY]
    INSERT INTO [Yearly_Sales].[dbo].[Product_Sales]
    VALUES(2010, 'Online', 'Web', 'Cameras', 'Electronics', 547, 0.00, 0, 0.00)
    EXEC [master].[dbo].[xp_cmdshell] 'bcp "SELECT * FROM [Yearly_Sales].[dbo].[Product_Sales]" queryout D:\Yearly_Sales\Product_Sales.dat -c -T -S'
    And the output I see in the file is:
    2010 Online Web Cameras Electronics 547 .00 0 .00
    The values before decimals are being truncated.
    Thanks,
    Bangaaram
    Known is a DROP, Unknown is an OCEAN.

    You can modify the decimal column(s) in the table to varchar type before export. But it does not look good.
    alter table [dbo].[Product_Sales]
    Alter column [Product_Amount] varchar(20)
    alter table [dbo].[Product_Sales]
    Alter column [Category_Amount] varchar(20)
    Does that make any sense?
    Known is a DROP, Unknown is an OCEAN.
    Basically you modify the decimal column to a varchar type before you run the bcp command for export. You can modify your source table or you can modify them on the fly. It is just a workaround.
    Modifying the source wouldn't be a good idea. Never do that if you can't get your desired output.
    Known is a DROP, Unknown is an OCEAN.

  • Purchase order with decimal values in held status.

    Hello, i have a SC. The quantity is decimal for the line item.When it was approved, the PO got a 'held' status.How do i release the PO and what can i do in order to accept decimal values in my SC ?

    Hello,
    Are you sure this is not a workflow issue?  If it is held, someone either placed it in hold status or something like that.  Since, there was nothing to suspect an application error, I don't think the decimals is your issue.  If you feel that it is, have you checked OSS.
    More information would be helpful....
    Regards, Dean.

  • Error saving purchase order data decimal values

    sir,
    PO was created with currency japanese YEN using Tcode ME21N . The net price was showing 142502300 (in JPY).
    when checked in EKPO table , it saved with a value 1425023.00  instead of  142502300 . 
    what can be done to correct this.      
    In PO Print out , it showing values as 1425023.00  which is wrong.
    SPRO>> NET WEAVER >> GENERAL SETTINGS >> CURRENCY>> SET DECIMAL values FOR CURRENCY CODES is showing 0 decimals against JPY (Japanese YEN)
    I want to know where else the Decimal values could have been set to 2 decimal places.
    FOr other currencies like US Dollars  there is no error.
    Regards,
    Srinivasa Murthy

    Hi Srinivasa,
    Use T. code OY01 and you can try 3rd option of decimal format that is 1234567, 89 for the same.
    Regards,
    Shailesh Verma

Maybe you are looking for

  • Photo Gallery: Looking For Suggestions

    Hi, all. I've been using JustSo PhotoAlbum quite happily for a few years and it continues to serve my needs well. One client, however, is requesting a gallery solution that would use JSPA-style popups, but with 'forward'- and 'back'-style navigationa

  • Hotsync.exe Runtime Error R6025 on Windows/XP Treo/650

    I'm running Windows/XP Home Edition with Palm Desktop ver 4/1/4 and Hotsync ver 6.0.1. I have a Sprint Treo/650 using Hotsync ver 5.4.0 (on the Treo) I recently activated my SprintPCS email account and I'm using VersaMail ver 3.1B When I Hotsync I ge

  • SUS SUPPLIER SELF-SERVICES

    Hi All, Unfortunately, the course of SRM215 (SUPPLIER SELF-SERVICES ) is read only in several countries (6-7) and then at the end of the year, please tell me where else can you find the information contained in this course in a book, or somewhere els

  • Help with updating adobe flash player

    I am using a macbook pro (safari) and trying to update my flash player but I can't seem to have any luck. I am on the webpage to download the player and when I double tap on the icon to install the player it takes me to a webpage which seems to be a

  • Intel hd graphics on windows 7 problem

    boot camp support software does not contain driver for intel hd graphics 3000 for windows. I have the early 2011 macbook pro 15" which has intel hd grapics 3000 and amd radeon hd 6490M. I've installed windows 7 home premium 64-bit in my macbook pro.