Rounding Decimal

Hi,
I'm ABAP beginner, how can i round the decimal number to an integer in ABAP report or SAPScript??  Which FM should i use??
Regards,
Kit

Hi
Check this Sample
DATA n TYPE p DECIMALS 2.
DATA m TYPE p DECIMALS 2 VALUE '-5.55'.
n = abs( m ).   WRITE:   'ABS:  ', n.
n = sign( m ).  WRITE: / 'SIGN: ', n.
n = ceil( m ).  WRITE: / 'CEIL: ', n.
n = floor( m ). WRITE: / 'FLOOR:', n.
n = trunc( m ). WRITE: / 'TRUNC:', n.
n = frac( m ).  WRITE: / 'FRAC: ', n.
ULINE.
floating points
DATA: result TYPE f,
      pi(10) TYPE c VALUE '3.14159265'.
result = cos( pi ).
WRITE result.
Thanks,
Praveen

Similar Messages

  • Having some trouble rounding decimal place

    Hello all,
    I am having some issues rounding a decimal in my code. My program is running and doing what I would like otherwise. Here is what I have so far:
    public class MortCalc2
         public static void main(String [] args)
              //Declare and initialize three variables
              double numloanamt = 200000.00; //loan amount of 200k
              double numinterest = 0.0575;  //interest rate of 5.75%
              int numtermyrs = 30;  //term of 30 years
              int numtermmths = 360;  //term of 360 months
              double numwholeamt = 545000.00;  //loan amount + interest
              double numpayment = 0;  //monthly payment
              numpayment = numwholeamt/numtermmths;  //payment equals loan amount plus interest divided by the total term in months
              System.out.println("Your monthly payment is $" + numpayment);
    }I am getting the results I want with the calculation except they are coming out as 1513.888888888889. I would like to see 1513.89. Can someone point me in the right direction. Thank you in advance for any help you can provide.
    Thanks,
    Seawall

    Hi, sorry for the first post.
    this works okay.
    import java.math.*;
    public class MortCalc2
         public static void main(String [] args){
    are and initialize three variables
    double numloanamt = 200000.00; //loan amount of
    of 200k
    double numinterest = 0.0575;  //interest rate of
    of 5.75%
              int numtermyrs = 30;  //term of 30 years
              int numtermmths = 360;  //term of 360 months
    double numwholeamt = 545000.00;  //loan amount +
    + interest
              double numpayment = 0;  //monthly paymen
    numpayment = numwholeamt/numtermmths;  //payment
    t equals loan amount plus interest divided by the
    total term in months
    numpayment =
    Math.round(numpayment*100.0) / 100.0;
    System.out.println("Your monthly payment is $" +
    + numpayment);
    Thats right, use an Irish screwdriver (a hammer) instead of the correct solution as posted by djmd02 in repsonse #3.

  • How to round decimal point to two places

    Hi all, I have been tasked with creating a custom "calculator" for a client that uses a specific equation. The client inputs data into two Input Text fields and the result shows up in a dynamic text field. Is there any way I can limit the number of decimal places to two? Here is my code (which works, except for the decimal issue):
    function onCalculate()
    one = Number(number_one);
    two = Number(number_two);
    result_1 = ((one / 4) * (65 / (1 - 0.25))) + ((two / 0.5) * (65 / (1 - 0.25)));
    Thanks in advance!!!!

    What will often be done is the result is first multiplied by 100, then rounded to an integer, then divided by 100.  So picking up from your last line where you calcvulate the result_1 value...
    result_1 = Math.round(result_1*100)/100;

  • Round decimal number to two places

    trying to round a decimal number to two places i.e. 1.98999 should round to 1.99.
    -tried using math.round but it only rounds to nearest integer
    -tried using decimalformat class but that converts to string, and cast wont allow me to convert from string back to double
    *is there a round method that allows you to specify decimal places?
    *or is there an easy method to cast a string back to a double?
    any advice is appreciated:)

    coynerm wrote:
    trying to round a decimal number to two places i.e. 1.98999 should round to 1.99.Agree.
    -tried using math.round but it only rounds to nearest integerI advise against rounding in most newbie situations. Usually it's the display of the variable you want to change.
    -tried using decimalformat class but that converts to string, and cast wont allow me to convert from string back to doubleOf course cast won't allow you to convert back. If you wanted to do that you'd use Double.parseDouble(stringVar); But we don't know why you are doing all this converting in the first place.
    *is there a round method that allows you to specify decimal places?
    *or is there an easy method to cast a string back to a double?Advice: Forgetting all this fooha with rounding, what in essence are you trying to achieve? Why all of this number manipulation in the first place? It will affect what should be the best answer.

  • Round Decimal value based on last digit

    Hi Experts,
    I'm trying to round the decimal value based on its last digit. If the last digit is >5 then add +1 to the digit before that and remove the last digit else just remove.
    ie.
    -59664.15000000005 should become -59664.15
    -21308625.00000002 should become -21308625
    -85234500.00000006 should become -85234500.0000001
    18288102.85714287 should become 18288102.8571429I tried with Round Function but it did not help,
    Pls assist.
    Thanks!

    Got it done just took the length and did the change.. sorry for this lame question.. should have tried before posting the question. Tx for your time...

  • FM to Round decimal place

    Hi Gurus,
    I want to reduce the number of decimal place by rounding off 2 decimal place.
    I am using 'HR_NZ_ROUNDING_DECIMALS' function module but its not working,
    kindly do the needful.
    Regards,
    Maithili

    Hi,
    Use Type cast method instead of finding FM.
    DATA : i type p decimals 4 VALUE '57846.5379'.
    DATA : j type p decimals 2.
    j = i.
    Write : / i.
    Write : / j.
    Regards,
    Velmurugan B

  • Pleas help with rounding decimal field

    I have a totals field that is summing several fields. I wish to have this totals field provide a rounded sum. I've tried setting the trailing digits to 0 but it will not round up, only round down. I have a display pattern for the field of num{($z,zzz,zz9.99)} . Example 162.59 is displaying 162.00 in total field instead of 163.00. Is there something I'm missing or am I missunderstanding how a decimal field works?
    code in "calculate" event:
    var test=xfa.form.topmostSubform.personnel_page.person_1.salary_cost1.rawValue+
    xfa.form.topmostSubform.personnel_page.person_2.salary_cost2.rawValue+
    xfa.form.topmostSubform.personnel_page.person_3.salary_cost3.rawValue+
    xfa.form.topmostSubform.personnel_page.person_4.salary_cost4.rawValue+
    xfa.form.topmostSubform.personnel_page.person_5.salary_cost5.rawValue+
    xfa.form.topmostSubform.personnel_page.person_6.salary_cost6.rawValue+
    xfa.form.topmostSubform.personnel_page.person_7.salary_cost7.rawValue+
    xfa.form.topmostSubform.personnel_page.person_8.salary_cost8.rawValue+
    xfa.form.topmostSubform.personnel_page.person_9.salary_cost9.rawValue+
    xfa.form.topmostSubform.personnel_page.person_10.salary_cost10.rawValue;
    //this rounds the value upon exit of field
    var result = MATH.round(test.value);
    this.value = result;

    In FormCalc you have a function which do just what you are looking for..
    Ceil(162.59)
    Put it in a messageBox and see the output..
    form1.#subform[0].Button1::click - (FormCalc, client)
    $host.messageBox(Ceil(162.59));
    OR
    You can use the Ceil function of the MATH object in Java Script.
    form1.#subform[0].Button1::click - (JavaScript, client)
    xfa.host.messageBox("" + Math.ceil(162.59));
    Thanks
    Srini

  • Rounding decimal numbers in the planning book

    Hi,
    Is there any way to round up the decimal numbers shown in the forecast/inventory/DRP planning book of SPP ?
    Thanks and Regards
    Mitesh

    Hi Mitesh,
    Please go to SPRO:
    APO -> Supply Chain Planning -> SPP -> Settings for user interfaces -> Assign Key Figures
    Go to "Semantic Maintenance"
    Set "Decimal Places" Column to Zero for all key figures.
    Regards,
    Aapka Mukundan

  • Help Round decimal 2 palces

    I have searched, but I cannot seem to find an answer to my question.
    I am a student in into to programing and I am trying to figure out why my decimals will not round. I have tried everything I can find, but being new to java programing, I am sure I am making a syntatical error somewhere. My program works other than not displaying the decimal places the way I want, 200.00 not 200.0.
    The following is my code, I have commented out each of the decimal formats I have tried.
    import javax.swing.JOptionPane;
    import java.text.DecimalFormat;
    import java.text.NumberFormat;
    public class CheckingAcct
         //int decimalPlaces = 2;
    // Truncates the big decimal value.
    //bd = bd.setScale(decimalPlaces, BigDecimal.ROUND_DOWN);
         //String string = bd.toString();
              //DecimalFormat df = new DecimalFormat ( "0.0#" );
                   //DecimalFormat twoDigits = new DecimalFormat ( "0.0#" );
              //DecimalFormat decimalFormat = (DecimalFormat)numberFormat;
              //decimalFormat.applyPattern("0.0#");
         public static void main (String args[])
              String strBalance,
                   strDeposit,
                   strChecks;
              double balance = 200.00,
              deposit,
                   lbcharge = 2.00,
                   nsfcharge = 25.00,
                   checks;
              //Display Starting Balance
              JOptionPane.showMessageDialog (null, "Your current balance is:$" + balance);
              //calculate balance
         strDeposit = JOptionPane.showInputDialog ("Please enter your deposit amount:$");
         deposit = Double.parseDouble (strDeposit);
         balance = deposit + balance;
         JOptionPane.showMessageDialog (null, "Your current balance after deposit is:$" + balance);
         strChecks = JOptionPane.showInputDialog ("Please enter the total amount of checks written:$");
         checks = Double.parseDouble (strChecks);
         balance = balance - checks;
         //Low Balance
         if (balance < 100.00)
              JOptionPane.showMessageDialog (null, "You have fallen below the minium required balance and you have been charged:$" + lbcharge);     
                   balance = balance - lbcharge;
              else
                   lbcharge = 0.00;
              //NSF Charge
         if (balance <= 0.00)
              JOptionPane.showMessageDialog (null, "You have a negative balance and you have been charged:$" + nsfcharge);     
                   balance = (balance - nsfcharge);
              JOptionPane.showMessageDialog (null, "Your current balance is:$" + balance);     
              else
              JOptionPane.showMessageDialog (null, "Your balance is:$" + balance);
         System.exit (0);
    }

    I tend to use super class NumberFormat, because I can
    never remember the jiggery-pokery of those patterns:
    import java.text.*;
    public class Example {
    public static void main(String[] args) {
    NumberFormat fmt = NumberFormat.getInstance();
    fmt.setMinimumFractionDigits(2);
    fmt.setMaximumFractionDigits(2);
    System.out.println(fmt.format(200.0));
    System.out.println(fmt.format(200.115));
    System.out.println(fmt.format(200.125));
    }Just be aware that NumberFormat/DecimalFormat uses
    half-even rounding.This confirms another thought I had, that I must format each number I want to use. Thank you.

  • Round decimal

    Hi everyone, I wish you all a happy new year!
    When I use round and the result is between 0 and 1, the zero disappears:
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    SQL> select round(1/190*100,2) || '%' from dual;
    ROUN
    .53%Is there an easier way to get the zero back instead of doing something like this:
    select decode(substr(round(1/190*100,2),0,1),',', '0' || round(1/190*100,2) || '%', round(1/190*100,2) || '%') from dualThanks in advance.

    Two ways (you probably want the latter as the first is SQL*Plus specific)...
    SQL> col rnd format 990.99
    SQL> select round(1/190*100,2) as rnd from dual;
        RND
       0.53
    SQL> select to_char(round(1/190*100,2),'fm990.99')||'%' from dual;
    TO_CHAR(
    0.53%
    SQL>

  • CFCHART rounds decimal on mouseover

    I have a bar chart that is graphing percentages all of which
    contain decimals.
    See this link:
    http://beta.kirrmar.com/?pgid=142&prodid=2
    The chart is correct, but when mousing over a series, the
    value displayed is not the actual value, but a rounded value. I
    need it to display 2 deciaml places when moused over. Any idea how
    this can be controlled?

    http://www.coldfusionjedi.com/index.cfm/2009/3/6/Ask-a-Jedi-Showing-the-values-on-a-chart

  • Rounding decimal to 2 for any MessageTextInputBean which is mapped to EO

    Hi,
    I have an requirement where in the MessageTextInputBean user enters the values in the format (###.##############################) i am able to store the same in the back-end too but in the Page level after clicking on the save button the value should be stored in the back-end as the user entered but in the page level it should display in this format (###.##). Is it possible or any work-around to achieve this.
    Thanks.

    Suraj,
    If its just to display on the page, u can format the bean value to currency, setAttributeValue(CURRENCY_CODE,"USD");
    --Mukul                                                                                                                                                                                                                                                                                                                   

  • Decimal places

    Decimal places are defined in the general settings.
    They are currently set to 2 decimal places.
    We have the required for 5 customers to be priced and invoiced at 3 decimal places.
    Is this possible?

    Hi Lisa,
    Please also notice the following information
    When you tick the option: Rounding By: Currency from the Administration-System Initialisation-Document Setting window.
    You could assign different rounding /decimal place per different currency
    ( Administration-Definition-Financial-Define Currencies)
    Hope this can be helpful.
    Best Regards
    Helen Sun

  • Regarding  Ronding off the decimal value

    Hi,
    i have a decimal number as " 58240990.00 " , i wanted this to rounded value .
    for example I am expecting to see 58241 for the above number.
    shell we can do in any way.. if so please let me knw fast.. it is urgent..
    thanks in advance.
    thanks,
    Suresh..

    Hi Suresh,
    Use <b>ROUND()</b> numerical function.
    ROUND(a) – round decimal places up and down
    ROUND(a,n) – round up and down to the nth place on the right of the decimal point
    ROUND(a,-n) – round up and down to the nth place on the left of the decimal point
    DATA V_F TYPE F VALUE '58240990.00'.
    DATA V_ROUND TYPE I.
    V_ROUDN = ROUND(V_F,'-4') 
    Thanks,
    Vinay

  • How do you wrap text around an image in Appleworks Word Processing?

    I need to do figure this out as soon as possible as it’s for a piece of college work due next week, so I’ll appreciate any answers you have to offer. All the help (online and otherwise) I’ve come across instructs me to go to non-existent ’Options’ or ’Tools’ menus - all I have is File, Edit, Format, Text, Outline, Table, Window and Help, none of which has an obvious solution. Ctrl-clicking on the picture only gives Help or Scale By Percent. Cheers for your help.

    Trinity Bourne wrote:
    When I go to 'text wrap' it asks me for a gutter number (which don't really understand). It doesn't matter what number I type in it always says 'invalid number' and won't wrap the text.
    "gutter" is a printers term that refers to the amount of (white) space between columns, or in this case between the edge of the floating object and the text wrapped around it. AppleWorks default value for this is 5 points (5/72 inch).
    AppleWorks should accept any value from 0 to 255 for the Gutter, and should round decimal values to the nearer integer value.
    In the example, the selected image (top left rectangle) had been set to "regular" wrap and the gutter left at 5 points. The rectangle to the right is set to "regular" and the gutter increased to 15 points.
    The oval on the right has the same settings (regular, 5 point gutter) as the selected rectangle; the one on the left is set to "irregular" wrap with the gutter setting left at 5 points.
    The left justified text in the example aligns itself along the right of the objects according to the regular/irregular setting: irregular follows the contours of the image, regular the outline of the 'box' containing the image. Irregular is available only for objects you have created using the AppleWorks Draw tools—imported/pasted images will include a white background filling the rest of the box.
    Note the lack of text between the left margin and the left edge of the selected rectangle. this is due to the space between margin and object is too small to accomodate any of the words (currently in the space between the two rectangles) that would fall into that space.
    Regarding the "invalid number" error message you are getting—I suspect this is a corrupted preferences issue. Some possible solutions are discussed in this thread, located by clicking the "more options" link in the search box (above right) then searching the AppleWorks Forum for "invalid number" (including the quotation marks).
    Regards,
    Barry

Maybe you are looking for

  • Part of audio no longer works

    I'm running PP CS5.5 and just started experiencing a problem I've never had before. First, here's the set up: The project: A series of talking head videos with 4 different people addressing 6 different subjects. Each video/sequence addresses a separa

  • Unable to open PNG files "not the right kind of document"

    I just noticed this error today when I tried to open several PNG files, some of which I created with Photoshop: "Could not complete your request because it is not the right kind of document". I'm running Photoshop 9.0.2 on Windows XP Pro. Opening oth

  • My macbook wont detect my projector. what can i do?

    my macbook wont detect my projector in detect screen display. what can i do? i have changed and bought new cables but no change. the computer seems to be the issue... thanks joe

  • Iphone 4 STOLEN today, trying to backup on 3G but don't know what I'm doing

    My iphone 4 was stolen today while out at the pool and out of sight for literally 10 minutes. There are no iphone 4s anywhere at any of the att or apple stores here so am forced to order a new one and wait the 5-10 days. Luckily my dad still has his

  • Out.println in jsp?

    Can out.println be used in JSP? I got the following error: I have googled that out.println cannot be used in a method declaration, which is what i've done. So what do i do from there? C:\Documents and Settings\USER\Desktop\FOS_Menu\FOS_Menu\build\gen