Decimals

How would you write the code for a simple operation so that the answer is given with decimals. For example, when I type:
console.out.println(15/4);
the console will print: 3. However the answer is 3.75.
Help me please. Thank you

Thank you. it worked.

Similar Messages

  • F4IF_INT_TABLE_VALUE_REQUEST not returning value with 2 decimals point

    hi all,
    i use function F4IF_INT_TABLE_VALUE_REQUEST to do search help, the master data in table ZINVEST has field ZNO, with field type CURR , 2 decimals point.
    the return table shows 2 decimals point but in display screen it only shows 1 decimal point, pls advice
    here's the coding:
    DATA : BEGIN OF itab OCCURS 0,
              e_value(20),
             END OF itab.
      DATA: BEGIN OF field_tab OCCURS 0.
              INCLUDE STRUCTURE dfies.
      DATA END OF field_tab.
      DATA : return_tab LIKE ddshretval OCCURS 0 .
          CLEAR field_tab.
          field_tab-fieldname = 'E_VALUE'.
          field_tab-intlen = 17.
          field_tab-outputlen = 17.
          field_tab-decimals = 2.
          field_tab-inttype = 'C'.
          field_tab-scrtext_m = 'Investment No'.
          APPEND field_tab.
          SELECT * FROM ZINVEST.
            CLEAR: itab.
            itab-e_value = ZINVEST-ZNO.
            APPEND itab.
          ENDSELECT.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield        = 'E_VALUE'
          dynprofield     = 'A'
          dynpprog        = sy-cprog
          dynpnr          = sy-dynnr
        TABLES
          value_tab       = itab
          field_tab       = field_tab
          return_tab      = return_tab
        EXCEPTIONS
          parameter_error = 1
          no_values_found = 2
          OTHERS          = 3.

    Hi ester,
    You shud try this way. Try to use this code.
    DATA:  BEGIN OF it_help OCCURS 0,
           zuonr TYPE zvinvoice,
           kunnr TYPE kunnr,
           name  TYPE zvcustname,
           END OF it_help.
    SELECT-OPTIONS: p_zuonr FOR bsid-zuonr.
    SELECT DISTINCT
             zuonr
             kunnr
      INTO CORRESPONDING FIELDS OF TABLE it_help
      FROM bsid
      WHERE zuonr <> space.
      SORT it_help BY zuonr kunnr.
      DELETE ADJACENT DUPLICATES FROM it_help
      COMPARING zuonr kunnr.
      IF it_help[] IS NOT INITIAL.
        SELECT kunnr
               name1
               name2
        INTO TABLE it_kna1
        FROM kna1
        FOR ALL ENTRIES IN it_help
        WHERE kunnr = it_help-kunnr.
        SORT it_kna1 BY kunnr.
        CLEAR v_tabix.
        SORT it_help BY kunnr.
        LOOP AT it_help.
          v_tabix = sy-tabix.
          READ TABLE it_kna1 WITH KEY kunnr = it_help-kunnr
                                      BINARY SEARCH.
          IF sy-subrc EQ 0.
            CONCATENATE it_kna1-name1 it_kna1-name2 INTO it_help-name  
            SEPARATED BY space.
            MODIFY it_help FROM it_help INDEX v_tabix
                                        TRANSPORTING name.
          ENDIF.
        ENDLOOP.
    FORM event_selscr_valreq_for_pzuonr .
    ***Function module to display the search help for the assignment filed****
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield         = 'ZUONR'
          dynpprog         = sy-cprog
          dynpnr           = sy-dynnr
          dynprofield      = 'P_ZUONR'
          window_title     = text-029
          value_org        = 'S'
          callback_program = sy-repid
        TABLES
          value_tab        = it_help
        EXCEPTIONS
          parameter_error  = 1
          no_values_found  = 2
          OTHERS           = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Reward if help ful.
    Regards
    Azad.

  • Decimals upto 2 in alv report

    Hi to all abapers,
    I have to show only upto 2 decimals in the field of an alv report but it is of type p and decimals 4.I dont want to change its type to 2 decimals due to some calculations.So can we show upto 2 decimals in the report?
    Thanks in Advance,
    Salish

    Hi,
    Here is the code
    <b>Here act_pckeff is of type p decimals 4 and i want it upto 2 decimals in the output.</b>
    PERFORM fldcat  USING i_fieldcat 'ACT_PCKEFF'       'DEC'       'Actual Efficiency "Packed"'    ''."13
    FORM fldcat USING p_ifieldcat TYPE lvc_t_fcat
                          value(p_name)
                          value(p_type)
                          value(p_desc)
                          value(p_key).
      DATA: w_fldcat TYPE LINE OF lvc_t_fcat.
      CLEAR w_fldcat.
      w_fldcat-fieldname = p_name.
      w_fldcat-datatype = p_type.
      w_fldcat-reptext = p_desc.
      w_fldcat-key     = p_key.
      IF w_fldcat-fieldname = 'AUFNR'.
        w_fldcat-no_zero = 'X'.
      ENDIF.
      IF p_type = 'CURR' OR p_type = 'QUAN'..
        w_fldcat-do_sum = 'X'.
      ENDIF.
      <b>IF p_name = 'ACT_PCKEFF'.
        w_fldcat-decimals = 2.
        w_fldcat-do_sum = 'C'.
      ENDIF</b>.
      APPEND w_fldcat TO p_ifieldcat.
    ENDFORM.                    " fldcat
    Regards,
    Salish.

  • ALV QUANTITY field Geting converted into decimals ?

    Hi All ,
    I have developed an alv report .In that the quantity field is made editable after editing the quantity when i save it .It gets converted into decimals.Suppose if i give 77 its getting reflected as .077 all the field name ,table name ,reference field name, reference table name, quantity field data type has been passed but the problem persists.If there is any one whos has come across this kind of scenario please share your thoughts on this.
    Best Regards,
    Sreeram

    Hi Sreeram,
    I am not gettin this issue. See below code :
    If you are gettiing the same issue with the below code then it has something to do with your user settings.
    Go to Menu Item System -> User Profile -> Own Data -> Defaults ->Decimal Notation.
    Set it to 1,234,567.89 and save. Now try the program again.
    REPORT z_test.
    TYPE-POOLS: slis.
    TYPES : BEGIN OF ty_ekpo,
              ebeln TYPE ebeln,
              ebelp TYPE ebelp,
              ktmng TYPE ktmng,
              menge TYPE bstmg,
            END OF ty_ekpo.
    DATA: it_ekpo TYPE TABLE OF ty_ekpo,
          it_fieldcat TYPE slis_t_fieldcat_alv.
    SELECT ebeln ebelp ktmng menge
      FROM ekpo
      INTO TABLE it_ekpo
      UP TO 20 ROWS.
    PERFORM add_fieldcat USING 'EBELN'.
    PERFORM add_fieldcat USING 'EBELP'.
    PERFORM add_fieldcat USING 'KTMNG'.
    PERFORM add_fieldcat USING 'MENGE'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       i_callback_program                = sy-repid
       it_fieldcat                       = it_fieldcat
      TABLES
        t_outtab                          = it_ekpo
    EXCEPTIONS
       program_error                     = 1
       OTHERS                            = 2
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    FORM add_fieldcat  USING  p_fieldname TYPE slis_fieldcat_alv-fieldname.
      DATA: wa_fieldcat TYPE slis_fieldcat_alv.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname = p_fieldname.
      wa_fieldcat-tabname = 'IT_EKPO'.
      wa_fieldcat-ref_fieldname = p_fieldname.
      wa_fieldcat-ref_tabname = 'EKPO'.
      IF p_fieldname EQ 'KTMNG'.
        wa_fieldcat-edit = 'X'.
      ENDIF.
      APPEND wa_fieldcat TO it_fieldcat.
    ENDFORM.                    " ADD_FIELDCAT
    Regards,
    Jovito

  • Dump when changing the value for a field (of 13 decimals) in alv grid.

    Hi Group,
    Its giving a dump when user is trying to change the value.
    dump description: Unable to interpret "70,000 " as a number.
    what is happening here is, the original value is 50,000 and he is deleting 5 and replacing it with 7, here its throwing the dump.
    If he removes the complete number 50,000 and then gives 70000 its  taking the value.
    I tried to use, the decimals options in alv field catalog but to no joy.
    Please can you give me an advice on this.
    Many Thanks.

    the problem is the comma in the 70,000....that's an alpha character.... Normally, we expect SAP to display numeric fields in a appropriate format, based upon their numeric type, but trying to forcibly insert '70,000' into a true numeric-type field can generate an 'unable to interpret xxx,xxxx  as number' error.
    You could experiment with changing your ALV column to a char17 (or appropriate width) and putting your numeric value into that to display, then converting back to type P, or other field type in the table, in a column that is not displayed, when the user changes the value....  essentially two columns, one not displayed with a routine to copy/convert the numeric field into the alpha field and the reverse when the field is changed.
    But, the better solution is probably for the user to understand that they're seeing a formatted numeric field, and that they need to replace the entire value with the only possible punctuation being a decimal and (if necessary) a negative sign.

  • Suppress Decimals for CURR field in ALV Grid based on condition

    Hello All,
    I am displaying records in ALV Grid. For a Company Code, I get the Currency Code from table T001.
    If the Currency is JPY, I want to display the value of CURR field without decimals.
    For example: if the value is 200.00, I want to display only 200
    But if the Currency is other than JPY, I want to display value with decimals.
    For example: if the value is 200.00, I want to display only 200.00
    Also I want the summation function to work on this column, so can't take the field as char field.
    Waiting for useful pointers.
    Thanks in advance,
    Regards,
    Tarun Gambhir

    Hi Keshav,
    Thanks for the reply.
    I have only one CompCode on the selection screen and for that CoCd I will have only one Currency.
    So either all records will be displayed with decimals or all records will be displayed without decimals.
    Can DECIMALS_OUT property of field catalog be helpful in this case.
    For reference you can check: http://help.sap.com/saphelp_erp2004/helpdata/en/ff/4649a6f17411d2b486006094192fe3/content.htm
    I am confused over the use of DECIMALS_OUT.
    Please suggest.
    Regards,
    Tarun

  • How to remove the display of DECIMALS in ALV? Any Falg?

    Hi Experts,
    One simle dount that, I am getting some values in some fields as 12.34; 11.22 etc - 2 decimals, but, am looking to hv as 12; 11 - NO DECIMALS.
    So, I looked any flag in Fileds catalog, Lay out in SLIS, but, did not find any flag?
    now, am getting it by moving to a P type field.
    But, pls.  let me know that How to get it done in ALV w/ SLIS? wht is the flag?
    thanq

    Check the field catalog, there is a field called  decimals_out,  set this to 0(zero).
    Regards,
    Rich Heilman

  • Sales order schedule line quantities in decimals

    Gurus - Required your help to resolve the following scenario.
    I'm facing with the problem where schedule lines of a sales order allocated with decimal quantities even though materials with UOM as EA(Each). For example Material A of sales qty 13 has the schedule lines allocated as 11.960 and 2.040. The delivery has been created as per the schedule lines with qty 11.960 and 2.040 and it has been pick/packed and delivered to the customer. Now, while issuing goods for the delivery, received the error message as <b>"Serial number management only allows whole numbers".</b>
    Can anyone provide what are the possible ways to round the delivered qty and issue the goods, when the delivery is complete?

    Sree - Question 1 - Why would you deliver the product and then try goods issue it (In general ;)...anyway....I know, a lot of companies do that way....
    Question 2 - How much exactly did you ship out, surely must not have shipped products in decimals, since you've EACHES defined and not KGs....or LBs...
    I would suggest finding out the correct quantities shipped out and then cancelling this delivery document....you can then go on to modify sales order schedule line accordingly and then process it again..."WHAT ABOUT PICK PACK DETAILS"....before cancelling this delivery doc out..capture the packing details (HUs) and then apply them to the new delivery doc... if you are using external system for packing HUs.....process the IDOC (or file etc) using the new delivery doc number....
    Hope you got the direction )
    Thanks
    Nikhil

  • How can I add decimals to my calculator? Percentages as well?

    I am building a simple calculator app. I have implemented my calculator this way: I have the viewcontroller.h and .m, I also have my "CalculatorBrain.h and .m" That is where I implement the addition and substraction, multiplication. I use the symbol or the text of the button to read it and calculate the value. The question is, if I have 1.5 plus 1.5, it says the answer is 2. It only takes the 1 and the 1. How do I add decimals? Also, if possible, how would I do percentages?
    This is my Calculator Brain.m:
    #import "CalculatorBrain.h"
    const NSString *Delete = @"D";
    @implementation CalculatorBrain
    - (void)setOperand:(double)anDouble
        operand = anDouble;
    - (void)performWaitingOperation
        if ([@"+" isEqual:waitingOperation]) {
            operand = waitingOperand + operand;
        } else if ([@"-" isEqual:waitingOperation]) {
            operand = waitingOperand - operand;
        } else if ([@"×" isEqual:waitingOperation]) {
            operand = waitingOperand * operand;
        } else if ([@"÷" isEqual:waitingOperation]) {
            if (operand) {
            operand = waitingOperand / operand;
    - (double)performOperation:(NSString *)operation;
        if ([operation isEqual:@"√"]) {
            operand = sqrt(operand);
        } else {
            [self performWaitingOperation];
            waitingOperation = operation;
            waitingOperand = operand;
        return operand;
    @end
    And this is my View Controller.m. Any suggestions?:
    #import "CalculatorViewController.h"
    @implementation CalculatorViewController
    - (CalculatorBrain *)brain
        if (!brain) {
            brain= [[CalculatorBrain alloc] init];
        return brain;
    - (IBAction)digitPressed:(UIButton *)sender;
        NSString *digit = [[sender titleLabel] text];
        if (userIsInTheMiddleOfTypingANumber) {
            [display setText:[[display text] stringByAppendingString:digit]];
        } else {
            [display setText:digit];
            userIsInTheMiddleOfTypingANumber = YES;
    - (IBAction)operationPressed:(UIButton *)sender;
        if (userIsInTheMiddleOfTypingANumber) {
            [[self brain] setOperand:[[display text] doubleValue]];
            userIsInTheMiddleOfTypingANumber = NO;
        NSString *operation = [[sender titleLabel] text];
        double result = [[self brain] performOperation:operation];
        [display setText:[NSString stringWithFormat:@"%g", result]];
    - (void) runTimer;
        // This starts the timer which fires the showActivity
        // method every 0.5 seconds
        myTicker = [NSTimer scheduledTimerWithTimeInterval: 0.5
                                                    target: self
                                                  selector: @selector(showActivity)
                                                  userInfo: nil
                                                   repeats: YES];
    - (void)showActivity;
        NSDateFormatter *formatter =
        [[NSDateFormatter alloc] init];
        NSDate *date = [NSDate date];
        // This will produce a time that looks like "12:15:00 PM".
        [formatter setTimeStyle:NSDateFormatterMediumStyle];
        // This sets the label with the updated time.
        [clockLabel setText:[formatter stringFromDate:date]]; 
    // Implement viewDidLoad to do additional
    // setup after loading the view, typically from a nib.
    - (void)viewDidLoad {
        [super viewDidLoad];
        // This calls the runTimer method after loading
        // SimpleClockViewController.xib
        [self runTimer];
    //  CalcController.m
    //  SimpleCalc
    //  Created by Chris Ball ([email protected]) on 1/17/08.
    //  Copyright 2008, Chris Ball, Strainthebrain.Blogspot.Com.
    //  All rights reserved.
    - (IBAction)resetEverythingPressed:(UIButton *)sender;
        if (userIsInTheMiddleOfTypingANumber) {
            [[self brain] setOperand:[[display text] doubleValue]];
            userIsInTheMiddleOfTypingANumber = NO;
        NSString *operation = [[sender titleLabel] text];
        double result = [[self brain] performOperation:operation];
        [display setText:[NSString stringWithFormat:@"0", result]];
    @end
    Oh, by the way, it tells the time. And if you want a screenshot, so you can see how it works out...

    For percentages, first make sure the number is < 0, then multiply it by 100, add a % sign and you're done
            double displayValue = [display.text doubleValue];
            if(displayValue < 0)
                displayValue *= 100;
                [display setText:[@"%" stringByAppendingFormat:@"%g", displayValue]];

  • How to remove decimals in ALV

    How to remove displaying decimals in ALV report(using FM) ?

    HI Sri,
       Pass the values into a variable of type i.
    data : var type i,
             var1 type f value '2.111'.
        var = var1.
    or else
    change the field catalog this way ..
    <b>lv_cat-decimals_out = '0'.</b>
    Regards,
    Santosh

  • How to remove Decimals in Quantity Objects in SAP BO Explorer View created on top SAP Bex Query?

    Hi,
    I created SAP BO Explorer report on top of SAP BEx Query.
    In SAP BEx Query, Decimals were hided but when i created OLAP Universe on top that SAP BEx Query and Created Index on top of Information Space in SAP BO Explorer and then created Exploration Views. But i'm getting Decimals in my Exploration Views where as SAP BEx Query in RSRT, no decimals were appearing.
    Can anyone suggest me how to remove decimals in SAP BO Exploration Views.

    Hi Ramana,
    I am not use how you connect to SAP BEx query (Via universe or BWA or HANA)
    What I could say is BWA and HANA, you cannot adjust this
    For universe, you could try in universe layer, there is note about this
    For BWA and HANA, this function might be enhanced but you 'd better raise OSS to SAP to check with them
    Best regards
    Alex yang

  • How to find the number of decimals in a given value

    Hi all,
    Can u please help me in solving the problem,
    i have a value called 5987.45
    and decimal places are 45 that is 2 numbers
    2) 765.987
    number of digits in decimals are 3.
    3) 67543.1
    number of digits in decimals are 1.
    for this i need a coding
    thanks.

    Hi,
    While printing your text element give as;
    &wa_tab-dec_value(.2C)&
    This will always print everything with 2 decimals.
    Regards
    Karthik D

  • How can I make a row of cells containing 3-digit decimals, who's values resulted from calculations within the spreadsheet, appear as durations of minutes and seconds?

    Row 6 in this spreadsheet is the result of Row 2/Row 3 as evidenced by the formula listed while Cell Y6 selected. How can I make the values in this row appear as durations of minutes and seconds rather than 3-digit decimals? For example, rather than appearing as 9.84 I would like the value of Cell Y6 to appear as 9:50 or 9min 50sec. (obviously .84x60seconds 50 seconds). I tried changing the cell formats from "number" to "duration," but no change is made. Using the "duration" format does however work if I am manually entering the decimal value into the cell rather than allowing it to result from another caluclation within the spreadsheet. Is there a solution to this within Numbers '09? You can see why I would want the "pace" displayed in minutes and seconds. Thanks in advance!
    Ryan

    Hi Ryan,
    You wrote:
    "The problem is that my "Distance" is a row of automatically generated values resulting from ((Row1/60)*Row 6). Changing the format of Row 1 to minutes causes row two to be expressed as a duration, which obviously it shouldn't because it is a distance. The spreadsheet has to be designed so that all I have to manually input on each entry are Row 1 Values (Time) and Row 6 Values (Average Pace). The rest of the cells must be automatically poulated as a result of formulas."
    I'm assuming that where you say "Row 1" in this you mean "Row 2", which is labeled "Time" in the example in the OP.
    In the original post, you presented a formula from cell Y6. Replacing the Header labels in that formula's cell reference with the Addresses of the referenced cells, the formula was:
    Y6: =Y2/Y3
    In this post, you are saying that Y6 contains entered data: "...all I have to manually input on each entry are Row 1 Values (Time) and Row 6 Values (Average Pace).
    Which is correct?
    Regards,
    Barry

  • Custom Table Currency field with 5 decimals

    Hello,
    I have created a custom table and it has a field for 'US Plan Cost'. The users wanted it with 5 Decimals. I have created a custom domain and custom data element of DEC Type with 5 Decimals.
    Domain: ZCOST: Data Type: DEC, No. of Characters: 11, Decimal Places: 5.
    However When I am trying to create entries in the table though, it's giving me error: Input must be in the format _____,_____,_____,_____~._____
    The entry that I am creating is: 1.23450.
    I dont know what went wrong? Can anybody please help me?
    Thanks Much.

    Are you doing this with SM30?  or from a program?  If a program, be sure your data value is precisely '1.23450'. It sounds like you're inputting something else...
    Or, post code?

  • How to change number of decimals in percentage agreement rebates

    Hi,
    I'm searching for a solution to have percentage amounts with 5 decimals instead of 3, in the conditions of rebate agreements.
    That's concerning transactions VBO1, VBO2, VBO3.
    Thanks for help.

    dear bras
    refer this
    Changing Data Types and Lengths of Existing Fields
    If a  data element is assigned to the field, you must change the technical field attributes (data type, length, number of decimal places) in the domain of the data element.
    Procedure for Fields with Data Elements
    Double-click on the name of the data element.
    The data element maintenance screen appears.
    Double-click on the name of the domain.
    The domain maintenance screen appears.
    Choose Domain ® Display ® Change.
    Make the required changes and save your entries.
    Note that this change affects all the table fields that refer to the particular domain. Foreign keys could become inconsistent and conversions required. You should therefore consider the effects of this action before changing the domain by choosing  in the maintenance screen of the domain and checking if the domain is used in other tables.
    Choose .
    The table is activated again and the table field is adjusted to the domain change.
    Procedure for Fields with Direct Type Entry
    Place the cursor on the field and choose Data element / Direct type.
    Values can now be entered in fields Data type, Length, DecPlaces and Short text.
    Change the entries for the data type, length and possibly the number of decimal places.
    Save your entries.
    Choose .
    Note that a table conversion will normally be necessary (see  Adjusting Database Structures) if you change the field attributes.
    rewards if it helps
    siva

  • Unit of measure EA allows transactions in decimals ? Is EA indivisible?

    Unit of measure EA allows transactions in decimals ? Is EA indivisible?
    There are two scenarios. While creating a Bill of material - based on the configuration (see below) if you enter a quantity with decimals for a part number for which the Basic UOM is EA the system displays a message "Unit of measure EA does not support decimal places" THIS IS GOOD AS EXPECTED
    While transacting using MB1B, MB1C, MB1A, MFBF, MIGO or other transactions the system DOES NOT check and it is currently allowing us to post with decimals (1.25, 1.312) for part number for which the unit of measure is EA.
    Was not EA supposed to be an indivisible unit of measure? why is the warning message getting activated while creating or changing a BOM and why not while transacting stock?
    We have configured EA in the CUNI transaction as follows:
    Int. meas. unit      EA                                                  
    Commercial           EA              each                               
    Technical            EA              each                               
    Decimal places                                                          
    float. point exp.                                                                               
    ISO code             EA            
                                          Primary code                       
    Numerator            1                                                  
    Denominator          1                                                  
    Exponent             0                                                  
    Additive constant    0.000000       X Commercial meas.unit               
    Decimal pl. rounding                 Value-based commt                  
    Unit of meas.family

    you cannot restrict this behaviour with CUNI customizing, you can only check and stop this in a user exit.
    SAP inventory managment allows and stores 3 decimals for any unit of measure. You can only define how it will show the value to the users and how it will round the decimals if it calculates the conversion. But if you enter manually with decimals, then SAP will not round this.
    please read OSS Note 931971 - Decimal places in stocks and stock postings
    and
    Note 77525 - Quantity unit conversion in inventory management

Maybe you are looking for