Printing only 2 decimal places

Hi people, thank again in advance for your help.
if i have a number with tons of decimal places behind it...and only wantto print on screen 2 (for instance when I am want $10.00 instead of $10.000000001) or somethign like that, what can i do?
With Math.round() work? but i also want such that if the figure is zero....to be printed $0.00 and not $0.0.
Can anybody helo?

Thanx mark. but when i tried i get these errors.
C:\WINDOWS\Desktop\BC201\assignment2\Savings.java:86: cannot resolve symbol
symbol : class DecimalFormat
location: class Savings
          DecimalFormat df = new DecimalFormat(".00");
^
C:\WINDOWS\Desktop\BC201\assignment2\Savings.java:86: cannot resolve symbol
symbol : class DecimalFormat
location: class Savings
          DecimalFormat df = new DecimalFormat(".00");
^
2 errors
Tool completed with exit code 1

Similar Messages

  • Printing to 2 decimal places

    i have my database in mysql and my field total is declared as decimal to 2 decimal place.....how to i get it to print to two decimal place in my JSP page...i have declared the variable as double but when it is printing it is printing to one decimal place only...please help

    don't declare ur column as decimal in MySQL . Declare as decimal(3,2);
    thanx,
    Samir

  • Getting an error in CIF Inbound queue:"Only 0 decimal places are permitted for unit of measure PC"

    Hi,
    I am getting an error in CIF Inbound queue (function: CIF_ORDER_INBOUND_30A). The error text says "Only 0 decimal places are permitted for unit of measure PC".
    Can anyone point out the solution to resolve this error? It would be a big help for me as I am new to APO and so getting difficult to find a clue for it.
    Thanks.
    Regards
    Mansi

    Hi Mansi,
    Please check the cif queue you will get the order number from that order number you can find out material code. Then check the material master unit of measure in MM03 you have used some alternative unit of measure and system is unable to convert order to  alternative unit of measure because of decimal setting. If you go to CUNI and check the unit if measure PC it is not permitted for decimal places. If you need decimal than change the UoMof Material and use diff UoM or allow the decimal for PC which is not good practice.
    Regards,
    R.Brahmankar

  • Printing to two decimal places on the screen

    Hi everyone...
    I am using mysql as my DB...my field is declared there as decimal(8,2) means to 2 decimal place..when i am getting the result i also need to print to 2 decimal place...
    so when i do(rs.getDouble("Price")) it is not printing as two decimal place...how do i get it to print to 2 decimal place...
    Thanx a lotttttt

    javax.text.DecimalFormat dfrm t=new java.text.DecimalFormat("#0.00");
    //or another format see API doc for DecimalFOrmat
    String result = dfrm.format(rs.getDouble("Price"));

  • Need only two decimal places, but BigDecimal isn't working

    Hello again. This time I've got a problem with getting only two decimal places. I tried using BigDecimal but when I compile it, I get an error "cannot find symbol class BigDecimal" and a "cannot find symbol variable BigDecimal".
    Grrr... I just want my value to have only 2 decimal places before it ends up in my text field.
    Any help will be appreciated.
    - Phonse
    if (ostuff1.equals("amt tendered"))
                     finalamt = total1 * 1.12;
                     change = cash1 - finalamt;
               BigDecimal finalamt2 = new BigDecimal(finalamt);
                  finalamt2 = finalamt2.setScale(2, BigDecimal.ROUND_DOWN);
                  BigDecimal change2 = new BigDecimal(change);
                  change2 = change2.setScale(2, BigDecimal.ROUND_DOWN);
                  finalamt = doubleValue(finalamt2);
                  change = doubleValue(change2);
                     addItem(String.format("Amount Tendered:          "+"P "+finalamt));
                     addItem(String.format("Change:                     "+"P "+change));
                   }

    @ georgemc
    Isn't it better to import whole packages instead so
    you can have everything available when you call them?
    I mean, it's kinda hard to import individual classes
    everytime you need to call them.No. You can get conflicts when importing complete packages. If you importjava.awt.*;
    java.util.*;and then declareList list;the compiler does not know which List you meant, java.util.List or java.awt.List.
    Offtopic @ prometheuzz
    LOL. When I was a kid still playing my Playstation I
    wanted to have a career in computers when I got to
    college. Now I'm 14 and a 3rd year high school
    student and I just got a reality check -- computers
    just isn't for me. And alot of those professionals
    say Java is the "easiest" programming language. O_O
    Meh. I'll just follow my other dream of becoming a
    chef. Just seems like my parents won't like it...
    Bleh... Two more years... Two more years...Sure, but if you like programming, work (hard) for it. Most people have to work hard in order to become good at something, no one is born as a programmer. This goes for becoming a chef as well.

  • Printing exactly 2 decimal places

    I'm trying to print my double type variables to exactly 2 places. but numbers such as 3.00 and 124.00 keep printing as 3.0 and 124.0. Is there an easy way to force the printing to two decimal places on a primitive double type value without having to cast it to a Double object and playing around with NumberFormat and all that entails?
    thanks much,
    jh

    darelln has exactly the right answer, except that you must do the thing you don't want to do. If it were me, I'd go with his example. It's less work and much cleaner.
    import java.text.*;
    public class DoubleTest {
    static double[] numbers = {3000, 124.12, 123.122, 3.0, 124.0, 10.2, 12.14, 1234.55};
    static final NumberFormat f = new DecimalFormat("#.00");
        public static void main(String [] args) {
            System.out.println("Goofy way!\n");
            for (int i=0 ; i<numbers.length ; i++) {
                printD(numbers);
    System.out.println("\nRight way!\n");
    for (int i=0 ; i<numbers.length ; i++) {
    System.out.println(f.format(numbers[i]));
    static void printD(double dbl) {
    if (dbl % 10 == 0) {
    System.out.println(dbl + "0");
    } else {
    String sdbl = "" + dbl;
    String predot = sdbl.substring(0, sdbl.indexOf("."));
    String atdot = sdbl.substring(sdbl.indexOf("."), sdbl.length());
    String postdot = sdbl.substring(sdbl.indexOf(".") + 1, sdbl.length());
    if (postdot.length() == 2) {
    System.out.println(sdbl);
    } else if (postdot.length() < 2) {
    System.out.println(predot + "." + postdot.substring(0,1) + "0");
    } else {
    System.out.println(predot + "." + postdot.substring(0,2));
    java DoubleTest
    Goofy way!
    3000.00
    124.12
    123.12
    3.00
    124.00
    10.20
    12.14
    1234.55
    Right way!
    3000.00
    124.12
    123.12
    3.00
    124.00
    10.20
    12.14
    1234.55
    and the results are identical!

  • Change screen field dynamically only for decimal places

    Hi,
    I have variable for which is declared to take upto 3 decimal places, my requirement is ...
    when this variable is getting populated for a particular screen i have to display decimal upto only 2 places, this data element is also used in other screens ao i cannot modify its domain directly...
    is there anyway i can do it dyanmically when values are getting populated on screen
    Regards,
    Prateek.

    Hi,
    If you want to use with WRITE statement:
    Effect of different DECIMALS specifications:
    DATA: X TYPE P DECIMALS 3 VALUE '1.267',
    Y TYPE F VALUE '125.456E2'.
    WRITE: /X DECIMALS 0, "output: 1
    /X DECIMALS 2, "output: 1.27
    /X DECIMALS 5, "output: 1.26700
    /Y DECIMALS 1, "output: 1.3E+04
    /Y DECIMALS 5, "output: 1.25456E+04
    /Y DECIMALS 20. "output: 1.25456000000000E+04
    If you want to use in ALV display - Fieldcatalog:
    *-Decimal places for Del Qty and Bag Wt
        IF p_fieldname = 'DELQTY' OR  p_fieldname = 'BAGWT'.
             ls_fieldcat-decimals    = '000002'.
        ENDIF.
      APPEND ls_fieldcat TO gt_fieldcat.
    Regards,
    ~Satya

  • Print Doubles to two decimal places?

    When I do calculations on my double numbers and then print them on screen I get a string of digits after the decimal point. Can anyone give me the code as to how I use the DecimalFormat class to make these digits print to 2 decimal places. I am sure it is very simple line or two of code but I am unsure how.
    Thanks

    double number = 123456.789;
    DecimalFormat df = new DecimalFormat("#,##0.00");
    System.out.println(df.format(number));
    DesQuite

  • Decimal places on forms

    The decimal places in General Settings>Display is set to 6 for Amounts and Prices.  They would like only 2 decimal places to acutally print on the SO and AR Invoice.  How can we do this?

    Hi Kathy,
    You can add another formular field with round(Field_XXX,2) to display only two decimal places for any fields. Then hide the long decimal field.
    Thanks,
    Gordon

  • Rounding a quantity field to one decimal place. PLEASE URGENT

    I have a quantity field with three decimal places. I have to print this field with only one decimal place. This is in a smartform.
    suppose: qty = 45.678
    I want it to be printed as 45.7
    Thanks in advance.

    Hi Riki,
    I think you can use Function Module ROUND to round off the value...
    REPORT ZTEST_SHAIL4 .
    data: out type p decimals 1,
    inp type f.
    inp = '45.678'.
    CALL FUNCTION 'ROUND'
    EXPORTING
    DECIMALS =
    input = inp
    SIGN = ' '
    IMPORTING
    OUTPUT = out
    EXCEPTIONS
    INPUT_INVALID = 1
    OVERFLOW = 2
    TYPE_INVALID = 3
    OTHERS = 4
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Now use the variable 'out' to display the rounded off value...
    Regards,
    SP.

  • Quantity field to one decimal place. PLEASE URGENT

    I have a quantity field with three decimal places. I have to print this field with only one decimal place. This is in a smartform.
    suppose: qty = 45.678
    I want it to be printed as 45.7
    Thanks in advance.

    Create one more variable in Global definitions with only 1 decimal place.
    Assign value of qty to this new variable.
    SAP automatically takes care of the rounding.
    And then print this new variable rather than qty.
    You can write all these in a code block.

  • Error while updating decimal places in general settings

    Hii All
             I have got an error while updating Decimal places in General Settings
    Cannot update while another user is connected to the company i have checked, there is no other user logged in, i could add other settings but the problem is only with Decimal Places
    Note : there are no postings yet, a fresh database for a new client
             what could be the possible reason
                                                                 thanks
                                                                         RIYAZ

    Hiii All
          As a forum rule, i have initially gone through with the existing threads and then i was force to post a thread,
              would be helpfull if there is any other way..
                                                Thanks
                                                         RIYAZ

  • Decimal places in excel

    Hi,
       I am sending quantity field to excel with three decimal places but when I open the excel after generating it shows only two decimal places.How can i obtain this function with excel it should show only 3 decimal places with thousand seperator.
    Regards,
    Karthik.k

    Hi,
    if you are sending your data with OLE try something like this:
    SET PROPERTY OF GS_CELL1 'NumberFormat' = '#,##0.000'.
    Kostas

  • Decimal Places in DSO

    Hi All,
    I'm trying to load a field from source system whose decimal length is 5. The InfoObject I created for this field is of data type Decimal and given decimal places upto 5 in additional properties of the InfoObject. I alos checked "Key Figure with Maximum Precicion". I loaded data into the InfoObject and its taking only 3 decimal places.
    Any solutions?

    Hello,
    I think its nothing to do with user parameters, it simply tells how the decimal format for that user is.
    I think you should be OK with the use of FLTP KF. Though it will show in exponential form in the display data, in the report it should be fine for the display with the needed decimal places (non exponential display in the report).
    Regards,
    Shashank

  • Decimal places in quantity depending on currency

    hi
    i m doing an alv list display in which i need to display a quantity field with 3 decimal places for some currencies, but for one particular currency such as 'AED'
    that field should display only 2 decimal places in the output.
    regards
    Zarina

    Hi Zarina,
    Populate decimals_out with 2 for this field while building the fieldcatalog.
      g_t_fieldcat-decimals_out = 2.
    Note: don't declare the field as currency which will overwrite above setting.
    i.e., don't use g_t_fieldcat-cfieldname in this case.
    ==============================================
      g_t_fieldcat-seltext_s =  'USD Equi'.
      g_t_fieldcat-seltext_m =  'USD Equi'.
      g_t_fieldcat-seltext_l =  'USD Equivalent'.
    g_t_fieldcat-cfieldname = ' '.
      <b>g_t_fieldcat-decimals_out = 2.</b>
      g_t_fieldcat-just      =  'R'.
      modify g_t_fieldcat index zindx.
    ==============================================
    Hope this helps you.
    Regards,
    Vicky
    PS: Award points if helpful

Maybe you are looking for

  • Error message in planning function

    Hi, I have implemented a plausibility check for values in a planning function: IF { Z6SLSPRIC } = 0 AND NOT {Z6SLSQTY}  IS INITIAL.      MESSAGE E000(ZOP1) .      MESSAGE E001(ZOP1).      MESSAGE I003(ZOP1). ENDIF. With raising an error message the d

  • I can't zoom in and out using the scroll wheel

      so i want to zoom in and out on photoshop how i always have...using ctrl and scroll wheel... but when i went to do it how i naturally do it, it didnt work..after some research i found you go into preferences, general and tick the box about zoom scr

  • Error printing pick list from IW32

    Hi all, When trying to print pick list from transaction IW32, I get this error message: Express document "Update was terminated" received from author ... When I checked out this error message in SM13, I found this: Transaction code: IW32 Module name

  • Importing relationship data

    Hello,   Any one could explain me steps for importing relationship data,  pre-requisites, source file structure.   I am very much confused about field mapping. It always give me error Failed to find the aggregation record from its field values. Any o

  • Burning Music CDs

    I have a basic educator's iMac Intel with a CD recorder. I am unable to create music CDs that are readable by CD players, which see only one large file. The file I was sent, n. 25402 was not very helpful, but it did point to one possible problem: the