Ceiling value of a double [decimal]

I have a double variable
double var = 100.1
I would like to know if there are any inbuilt functions to get the ceiling value of this variable. Ideally
ceiling(var) should give me 101.

Take a look at the 'ceil()' method in class java.lang.Math:
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Math.html#ceil(double)

Similar Messages

  • Converting a string to the corresponding value of type double

    Hey, im a really noob at this, but I need some help with this question. I've got to complete this in order to progress to my second year although im not doing programming and will not need it in the second year. The question is as follows:
    "Write a method called convertDouble as follows:
    public double convertDouble (String value) {
    This method should convert its parameter (a string like "3.1415") to the corresponding value of type double. If the string supplied is not a valid number, it should return 0.0 as its result. Note that you can use the method Double.parseDouble() to do the hard work for you. "
    To be honest I dont really have a clue what how to write this so any help would be much appreciated. Cheers guys

    Well the simplest way is to use Java's already inbuilt converter:
    which is if you have a string S which represents a double i.e 3.142
    You can use
    double number = Double.parseDouble(S); and thats it.
    The other way to do it is to loop through the string and check whether it is a number
    by using Character.IsDigit(ch) ? or somethign similar.
    and if it is a digit then subtract a fixed amount depending on its ASCII value.
    so if character with a value of 40 represents 0 (im not sure if it does) then
    any Digit character - 40 would give you the decimal value.
    Please ask questions if i dont make sense.
    Edited by: z0rgy on Aug 18, 2008 7:36 AM

  • PTO Accruals - Ceiling value needs to be grade based

    Release 11i.10.2
    Details of the plan
    =============
    Accrual Formula = PTO_PAYROLL_BALANCE_CALCULATION
    Carry Over Formula = PTO_PAYROLL_CARRYOVER
    Payroll Balance Reset Date = 1st January
    Period of Ineligibility = 6 months
    Accrual Band
    Years of Service = 0-99
    Annual Rate = 30
    Maximum Carry Over = 15
    Requirement
    ========
    Ceiling is to be 60 for employees in Grade A1-A5 and for the rest there is not limit.
    Can someone please help me? The Standard form does not seem to fulfill the needs and when I open forumlas PTO_PAYROLL_BALANCE_CALCULATION, PTO_PAYROLL_CARRYOVER I am unable to understand exaclty which part of the code should be modified.
    Pls Help
    Regards
    Woqar

    To achieve your requirement, you need to change the accrual sub formula PTO_PAYROLL_PERIOD_ACCRUAL. Follow the below steps.
    A.Create a pl/sql function :
    1. Create a new Pl/Sql Function in similar lines with parameters as p_assignment_id, p_date_earned, p_plan_id and p_number_of_years;
    2. The new function should call the pl/sql function per_utility_functions.Get_Accrual_Band passing values of p_plan_id and p_number_of_years.
    3. After the above function call, invoke your custom procedure to get the accrual value based on grade (passing p_assignment_id and p_date_earned as parameters).
    4. call the procedure per_formula_functions.set_number to set the ceiling value.
    So overall your function should like this
    FUNCTION <function name>(p_assignment_id NUMBER,p_date_earned DATE,p_plan_id NUMBER, p_number_of_years NUMBER ) RETURN NUMBER IS
    < variables declaration>
    l_ceiling number;
    BEGIN
    l_return := per_utility_functions.Get_Accrual_Band(p_plan_id,p_number_of_years);
    IF l_return = 1 THEN
    return l_return;
    ELSE
    l_return := <your custom function>(p_assignment_id,p_date_earned,l_ceiling);
    l_error := per_formula_functions.set_number('CEILING' ,l_ceiling);
    END IF;
    END <function name>;
    l_error := per_formula_functions.set_number('CEILING' ,l_ceiling);
    B. Create a Formula Function with the above pl/sql function with p_assignment_id, p_date_earned, p_plan_id as context usages and p_number_of_years as parameter.
    C. Copy the Formula PTO_PAYROLL_PERIOD_ACCRUAL and replace the entry of Get_Accrual_Band with your custom formula function defined in step B.
    D. Copy the formula PTO_PAYROLL_BALANCE_CALCULATION and replace the entry of PTO_PAYROLL_PERIOD_ACCRUAL with your custom formula defined in step C.
    Hope this helps.
    Regards,
    Sharath

  • How do i convert a float value to a double value?

    How do i convert a float value to a double value? HELP PLEASE!! im very stuck!! i gota float data type and i need to convert it to a double data type in order to use it in another operation.....
    thank u so much!

    safe dint realise ppl were so arrogant. thanks for the reply but less of the sarcasm!

  • CL_SALV_TREE: How to read the value of a double-clicked field

    Hey Guys!
    I have build a list with CL_SALV_TREE. When the user makes a DOUBLE CLICK in a especially field of a line I want to call a transaction with the field's value.
    Can you please tell me how exactly I can get the value of the double-clicked field?
    Reacting on the double-click-event is no problem (thanks to the sap-sample-codes), but I just don't know how to find the item-value having node-key and columname.
    I got this far:
    *       CLASS lcl_handle_events DEFINITION
    class lcl_handle_events definition.
      public section.
        methods:
          on_double_click for event double_click of cl_salv_events_tree
            importing node_key columnname.
    endclass.                    "lcl_handle_events DEFINITION
    *       CLASS lcl_handle_events IMPLEMENTATION
    class lcl_handle_events implementation.
      method on_double_click.
    *   selecting field's value
    *   call transaction
        message i000(0k) with node_key columnname. 'just for test
    endmethod.                    "on_double_click
    endclass.                    "lcl_handle_events IMPLEMENTATION
    I googled a lot and also searched in this forum and found some questions to a similar topic, but no solution to my problem.
    Can you help me with some example-code?
    Thank you very much!!!

    You need to get the Node and node value of the selected column like this.
    METHOD on_double_click.
        DATA: lr_nodes TYPE REF TO cl_salv_nodes,
              lr_node  TYPE REF TO cl_salv_node,
              lr_val   TYPE REF TO  cl_salv_item,
              lr_data  TYPE REF TO data.
        FIELD-SYMBOLS: <lv_val> TYPE ANY.
        lr_nodes = gr_tree->get_nodes( ).           " All nodes
        lr_node = lr_nodes->get_node( node_key ).   " selected node
        IF columnname IS NOT INITIAL.
          lr_val =  lr_node->get_item( columnname ).   " Object for selected column
          lr_data = lr_val->get_value( ).              " value of selected column
          ASSIGN lr_data->* TO <lv_val>.
        ENDIF.
      ENDMETHOD.                    "on_double_click
    Regards,
    Naimesh Patel

  • Double value truncated to two decimal places without rounding the value.

    I want to truncate double value to two decimal places without doing the rounding of the value.
    Is there any method which can directly do the truncation.

    There's many ways to achieve this such as using
    BigDecimal's setScale method or type-casting. This is
    the way I like to do it:double d = -5.239;
    d = d > 0 ? Math.floor(d * 100) / 100.0 : Math.ceil(d
    * 100) / 100.0;
    Your division by 100 may cause an rounding error, because there are numbers which no finite binary representation. That's splitting hairs! I know ;-)

  • Long / double value convertion to Packed Decimal

    Hi,
    Could anybody tell me how to convert a long / double value to Packed Decimal (AS400) ?
    Thanks,
    Probir

    Now I'm writing this value in a flat file by
    FileOutputStream and sending to mainframe through FTP.
    But the mainframe people said it's not converted into
    packed decimal. Is it the right way to convert ??When you say "mainframe" I assume you are referring to a machine that uses EBCDIC. Java, even on the iSeries, uses Unicode and not EBCDIC, so when you FTP anything to the mainframe it will go through an ASCII-to-EBCDIC conversion. You want this to happen for text but you don't want it to happen for packed decimals; your carefully-constructed x'12' x'3f' bytes will be dutifully converted into EBCDIC garbage.
    FTP of an iSeries file (in the QSYS.LIB file system) to a mainframe is trivial because both client and server use EBCDIC, so there are no conversion issues. So if you could do it that way, you definitely should. Otherwise you are going to have to take your packed decimal data and replace it by the bytes that would be translated into it if it were in EBCDIC. The translation table QEBCDIC in library QSYS shows you how it does that, so use that table. You can look it with the command WRKTBL QSYS/QEBCDIC. You'll notice for example that x'09' in ASCII gets converted to x'05' in EBCDIC. So if you want to get x'05' into part of a packed decimal field on the mainframe, you have to send it x'09'. And so on. Like I said, I would recommend doing something other than this. Ask the mainframe people to not make you used packed decimal, for example.
    PC&#178;

  • Setting precision value of float/double

    Hi,
    I am retrieving data from database in to a float/double datatye. when i display the value it is showing the decimal of 4 to 5.(ex:4325.65785) but i want to display it as (ex:4235.65).
    Thanks
    Gopi

    import java.text.DecimalFormat;
    public class FormatTest
         public static void main(String[] args)
              DecimalFormat df = new DecimalFormat("##0.00");
              double d = 123456.2345678;
              System.out.println("Formatted: " + df.format(d));

  • Can I pass a string value to a double numeric indicator?

    I am doing a sequence of tests and saving each tests datas. When I bypass one of the tests, I need the string value 'BP' to get saved ( in the double numeric indicator ) for that particular test. Is there any possible way to do that?
    Solved!
    Go to Solution.

    The numeric indicator works like a "Format into String" function with a hardwired numeric input.
    So it really is a string indicator in the end.
    You can use the "Format String" property node to modify how the numeric is displayed.
    (Also available in Display Format ... --> Advanced Edit Mode.)
    I don't think you can avoid displaying the numeric value, but you can add text.
    So you could, for example, display: "0  BP".
    Format string normal = "%#.2f";
    Format string adding "  BP" text  = "%#.2f  BP";
    Some of the suggestions by others on this thread might be easier to manage and give a better result.
    (You have to swap Format Strings around and still have the numeric displayed.)
    *Note however, that this technique can be used to do interesting things like add Units to your numeric indicator.*
    steve
    Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
    question. Give "Kudos" to replies that help.

  • Stock Value (VPRS- VRPRS ) doubled in COPA

    Dear Gurus,
    In COPA the value field  (VRPRS) stock value shows the exactly double., where as in the sales order it shows correctly.
    Is there is any way to correct the error of showing the VRPRS as exactly double for documents already posted for prior years=2007,2008
    This situation happened when we went for upgrade where in we forgot to put the standard user exit which will deactivate the existence of 2 VPRS condition type values at the same time where in only 1 VPRS condition type will be made active.
    We found this after upgrade and were able to correct this by moving the user exit code to Production and arrested the duplication of VPRS condition value update happening in  Profitability Analysis documents prospectively. 
    The client  is now asking us to rectify the duplicate VPRS value updated already for previous years in COPA.
    The value of COGS from FI side is okay for all the documents
    Is there any way we can rectify this?
    We have tried by deleting the existing COPA document generated with duplicate entry and subsequently posted the same sales order via Transaction code KE4F (Prepare subsequent posting of Incoming Sales orders to COPA) KE4S Transfer SD Billing documents to COPA and checked again the values for VPRS is doubled.   For information, presently the sales order contains value of VPRS (Cost) shows correct values (single time only and no duplication of the same)
    Thanks in Advance
    Sivkaumar S

    Dear Venkat
    Thanks for your input
    We tried the BAPI the field CE11000-VRPRS (Stock Value in COPA) we want to change. 
    In BAPI we are giving the input as
    OPERATINGCONCERN                1000
    TESTRUN                         X
    Tables
    1.  INPUTDATA
    RECORD_ID                      000000
    FIELDNAME                      CE11000-VRPRS
    VALUE                          -68.93
    CURRENCY                       USD
    2. FIELDLIST
    FIELDNAME                      CE11000-VRPRS
    We are getting the below error messages
    TYPE                           A
    ID                             KEBAPI
    NUMBER                         251
    MESSAGE                        Invalid field list: field name CE11000-VRPRS
    LOG_NO
    LOG_MSG_NO                     000000
    MESSAGE_V1                     CE11000-VRPRS
    MESSAGE_V2
    MESSAGE_V3
    MESSAGE_V4
    PARAMETER
    ROW                                    0
    FIELD
    SYSTEM                         QS1CLNT400
    Kindly help me on the above
    Thanks in Advance
    Sivakumar S

  • JPY value shifted to two decimal places in the EBAN  Table

    Hi folks,
    We are in SRM 4 SP13 and ECC 4.6 C  Classis Scenario.
    When a  SC is raised in JPY currency  ,the  total value is carried to  PR in the backend correctly.
    But in the EBAN  table  under the PRIES field ,the total  value is shown as  the 1/100 of the value.
    This is happening only with JPY currency( no decimal values).
    So the report based on this total value is not showing the correct  value of the SC.
    Please let me know if I need to implement any changes or note to be applied.
    Thanks in advance,
    Rajesh

    Hi Masa ,
    Thanks for the reply.
    I displayed the PR  through ME53N in the backend. It displays the correct value in the valuation field.
    But whencheck the same in the EBAN table under PRIES it is showing 1/100 fo the value.
    We have a customised report which picks up this value from this table.
    Regards,
    Rajesh

  • Float / Double Decimal Display

    How do you get a float or double to display a certain amount of decimal places?
    For example, dealing with money, to have it be displayed as $1.30 instead of $1.3

    Use NumberFormat class!
    A simple example:
    NumberFormat currency = NumberFormat.getNumberInstance();
    currency.setMinimumFractionDigits(2);
    currency.setMaximumFractionDigits(2);
    System.out.println(currency.format(AnyValue));

  • Table values to have more decimal places

    Dear Experts,
    In one of the LIS table S022 , the value is updating up to one decinal place only. We want this value to have atleast 2 or 3 decimal places . How to make it effective.

    Hi
    As u have not mentioned for which field the value is updating with 1 decimal its difficult to say but I assume it is related to time. As per the field attributes in the table structure for S022 for all time and capacity related fields the decimal places defined as 1 only hence the data is updating with 1 decimal place.
    U can check this in SE11 by entering S022 in the fields tab.
    In order to increase the decimal places in table u need the Help of ABAPer with Access key
    Regards
    Brahmaji

  • Format a number with a decimal to show the value but not the decimal point

    I have a value of 129.50 in the DB. I'm using the htp.prn() function to export this value to a txt file. I have the field padded with leading 0s (so it looks like 0000129.50)
    I need to keep the value for the .50 but don't want the decimal point to show up (so I need it to look like 000012950) but can't figure out how to make it keep the value for the .50 but not actually show the decimal point - any ideas? (APEX 4.0 11g)

    Multiply by 100 and remove the formatting. htp.prn (to_char (number_item, '99999999999'));
    Edited by: Kleber M on Sep 14, 2011 5:10 AM

  • Field value is getting double while updating the database table

    Hi Experts,
    A simple doubt :
    there is a standard program through which a zfunction module is getting triggered, through this zfunction module i am updating the database table.
    Now what happening is one of the field(KCQTY) value in database is getting double at a time when i am executing the Program with same variant only.
    I have also done the CLEAR & REFRESH internal tables starting of the Function module.
    Can you please help me out.
    Max points wil be awarded.
    thanks
    rico.

    Hi Nicole,
    this is the part of the coding where you can see how the field KCQTY is getting moved in the loop statement.
      DELETE IT_CE20002B_815 WHERE
          KONDA = SPACE  OR
          WERKS = SPACE  OR
          VVB01001 < 0.
        LOOP AT IT_CE20002B_815.
          INDX = SY-TABIX.
          CONCATENATE IT_CE20002B_815-PERBL0(4) IT_CE20002B_815-PERBL5(2)
                                                    INTO MONAT.
       MOVE itab_ce20001b-perbl TO monat.
          CLEAR S815.
          READ TABLE IT_ZPL_MCS5 WITH KEY KONDA = IT_CE20002B_815-KONDA
                                           BINARY SEARCH.
            SELECT SINGLE * FROM S815 WHERE VRSIO = '000'
                                         AND SPMON = MONAT
                                         AND KONOB = 'APO'
                                         AND MVGR2 = IT_CE20002B_815-KONDA
                                         AND PRODH = IT_CE20002B_815-PRDHA
                                         AND WERKS = IT_CE20002B_815-WERKS.
                                        AND VTWEG EQ CO_VTWEG_99.
    BREAK SAMEE.
          IF SY-SUBRC EQ 0.
    Eintrag in S810 existiert
            IF S815-AEMENGE <= IT_CE20002B_815-VVB01001.
    wenn die Auftragseingangsmenge kleiner gleich der Kontingentsmenge
    wird die Kontingentmenge in das Steploop übernommen
              MOVE IT_CE20002B_815-VVB01001 TO  W_T_DATA_815-KCQTY.
    *Liste ausgeben
             PERFORM AUSGABE4.
              PERFORM AUSGABE4_815.
            ELSE.
    Ausgabe Fehlermeldung, wenn die Auftragsmenge größer als die
                           Kontingentmenge ist.
    *Liste mit fehlermeldungen ausgeben, Kontingent trotzdem übernehmen
              MOVE IT_CE20002B_815-VVB01001 TO  W_T_DATA_815-KCQTY.
             PERFORM AUSGABE_FEHLER4.
              PERFORM AUSGABE_FEHLER4_815.
            delete it_ce20002b index indx.
            continue.
            ENDIF.
          ELSE.
    Es existiert kein Eintrag in S810, dann direkt eingeben
            MOVE IT_CE20002B_815-VVB01001 TO W_T_DATA_815-KCQTY.
            MODIFY IT_CE20002B_815 INDEX INDX.
    *Liste ausgeben (Kein Eintrag in S810)
           PERFORM EINTRAG2.
            PERFORM EINTRAG2_815.
          ENDIF.
    *Übergabestructur für die Weiterverarbeitung durch das Copymanagement
    *im Functionsbaustein wird gefüllt.
          W_T_DATA_815-SPMON = MONAT.   "itab_ce20001a-perbl.
          W_T_DATA_815-KONOB = CO_KONOB_APO.
          READ TABLE IT_ZPL_MCS5 WITH KEY KONDA = IT_CE20002B_815-KONDA
                                          BINARY SEARCH.
          IF SY-SUBRC EQ 0.
            W_T_DATA_815-MVGR2 = CO_MVGR2_999.
          ELSE.
            W_T_DATA_815-MVGR2 = IT_CE20002B_815-KONDA.
          ENDIF.
          W_T_DATA_815-WERKS = IT_CE20002B_815-WERKS.
          W_T_DATA_815-PRODH = IT_CE20002B_815-PRDHA.
         W_T_DATA_815-VTWEG = '99'.
         W_T_DATA_815-KUNNR = '9999999999'.
          W_T_DATA_815-KCQTY = IT_CE20002B_815-VVB01001.
          W_T_DATA_815-BASME = IT_CE20002B_815-VVB01_ME.
    JR181005 - begin of ins.
         w_t_data_810-matkl = it_ce20002b-matkl.
    JR181005 - end of ins.
          APPEND W_T_DATA_815 TO TAB_DATA.
          CLEAR IT_CE20002B_815.
        ENDLOOP.
    thanks for reply
    rico

Maybe you are looking for

  • Failed to invoke startup class "MyStartup Class"

    Hi, I configured StartUpClass.java in Weblogic server through Admin Console . Also I set the required jar files in the classpath of the server in WL_HOME\server\bin\startWLS.cmd. This StartUPClass is written to initialize and create the minimum numbe

  • Will updated workflow affects previous items in list?

    Hi All, I have list form associate with list workflow and contains more than 10 items where workflow status for all is in In-progress. Once i update current workflow, will affect previous 10 items or not?

  • Not able to connect from SQL PLUS

    Hi All, I am able to connect from sqlplus.exe which is server db_home but when try to connect from sqlplus.exe which is in client_home ,getting following error ORA-12560: TNS:protocol adapter error I tried 'C:\app\client_home\sqlplus.exe system/syste

  • Best way to move data from page to page inside app

    Hi all I started writing this and it got way to complicated to explain in full without a novel. Breif description. I am using query string that starts in the parent window (from href in json file) it then has to be moved into the iframe url when movi

  • HTTP Binding limitation in SOA Suite 11.1.1.5

    Hi, We are using BPEL to integrate our systems with 3rd party systems, where we are the consumer of the service given by external vendor. The external vendor exposes XML based service (REST services) and have given a url to perform certain functional