How to stopping rounding  using decimal format

my problem is as
1. I am taking a double input in a jtextfield
2. Now i am using decimal format to round it to 6 decimal places
Now , how to make sure that decimal format while formatting do not round
like If input is 1.2345678 i want to get 1.234567 not 1.234568

That's not really an SCCSE.
Anyhow, why not just use Double.parseDouble() if you don't want any rounding etc. Don't forget to catch the NumberFormatException:
parseDouble
public static double parseDouble(String s)
throws NumberFormatException
Returns a new double initialized to the value represented by the specified String, as performed by the valueOf method of class Double.
Parameters:
s - the string to be parsed.
Returns:
the double value represented by the string argument.
Throws:
NumberFormatException - if the string does not contain a parsable double.
Since:
1.2
See Also:
valueOf(String)

Similar Messages

  • Rounding with decimal format

    im trying to use decimal format and at the same time round numbers
    code:
    dformat = new DecimalFormat("0.0");
    test = dformat.format(num);
    but if num is .65 it just shows .6 when i need it to be .7
    any suggestions.
    thanks

    because it uses BigDecimal.ROUND_HALF_EVEN rounding mode, as per the API docs saying so......
    ... of course, for the life of me (I blame it on Monday.... yes, I know it's not Monday.... still) I can't remember the right way to do it..........
    sorry..
    brain freeze warning...
    must go home and reboot....

  • Help needed : Formatting a double using Decimal Format

    Hi Everyone,
    I am having trouble formatting doubles. Basically I recieve a double and an int that represents the number of decimal places.
    From this I have to round the double. This is no problem, and is carried out as follows:
    public static String roundDouble(double d, int scale){
    BigDecimal big_decimal = new BigDecimal(d);
    java.text.DecimalFormat formatter = new java.text.DecimalFormat();
    formatter.applyPattern("########.#######");
    double dubble = big_decimal.setScale(scale,BigDecimal.ROUND_HALF_UP).doubleValue();
    return formatter.format(dubble,new StringBuffer(),new java.text.FieldPosition(formatter.FRACTION_FIELD)).toString();
    This work fine for me. (I use a DecimalFormatter to convert exponential in to actual). However my problem is that when my colleuge uses this method from a different locale it all goes wonky.
    In my locale of UK given something like 0.92742999999999 with 4 dp I get
    0.9274. In his locale which is Germany, he gets 0,9274.0000
    I assume I need to use DecimalFormatter.applyLocalizedPattern, but what should the pattern be?
    regards,
    dr_n35s

    formatter.applyPattern("########.#######");# before the decimal point have no effect on the format.
    This work fine for me. (I use a DecimalFormatter to
    convert exponential in to actual). However my problem
    is that when my colleuge uses this method from a
    different locale it all goes wonky.
    In my locale of UK given something like
    0.92742999999999 with 4 dp I get
    0.9274. In his locale which is Germany, he gets
    0,9274.0000The pattern for the UK should be ".#######"
    The pattern for DE should be ",#######"
    I assume I need to use
    DecimalFormatter.applyLocalizedPattern, but what
    should the pattern be?You can't hard code values into your code, use a properties file to localize your program.

  • How to stop Quicktime using IE Proxy Settings

    Hi there,
    My company's Proxy Server (Microsft ISA Server) requires Windows Integrated authentication which Quicktime does not support so QT web access fails.
    We have a Winsock Proxy component installed on the clent but for this to come into play we need to configure Quicktime not to use IE Proxy Settings as otherwise QT tries to talk to the Proxy server and cannot authenticate.
    I have spent a number of hours looking into this but cannot find any way to do this. I know a lot of app's allow you to turn off using IE's Proxy settings and wanted to se if anyone knew how to do this with QT.
    Thanks in advance for any help on this,
    Ian
    Toshiba   Windows Vista  

    Why not just right-click and save the linked file to your computer?
    Open the .mp3 with any app you choose.
    You can disable the QuickTime plug-in from playing .mp3 files in a browser window by opening the QT Control Panel/Advanced and click the MIME Settings button. Remove the check mark for the .mp3 format and restart your browser for this change to take effect.

  • Using decimal format

    How do I convert this number "5.14562" to this format "$5.15".
    I looked through the tutorials but wasn't sure how I would create the object or what to use.
    Is it DecimalFormat twoDigits = new DecimalFormat("$#,###.00")?
    What package do I have to import?
    Thanks

    Is it DecimalFormat twoDigits = new DecimalFormat("$#,###.00")?
    Yes that's bang on.java.text.DecimalFormat twoDigits = new java.text.DecimalFormat("$#,###.00");
    String answer = twoDigits.format(theDouble); // or theFloat

  • How to send mail using HTML format using tags

    Hello experts,
    I am currently using FM SO_NEW_DOCUMENT_SEND_API1 to send e-mails to our users' Outlook accounts. Now, I converted its document type from 'RAW' to 'HTM'. I enclosed my texts in HTML tags. But the problem is, I cannot see a thing when I check my message in SCOT. It just opens internet explorer and thats it. Anyway, Below is my code:
    get e-mail addresses of controllers in table ZSHIPTO_EMAIL
      SELECT * FROM zshipto_email
      INTO TABLE it_zshipto_email
      WHERE zevent = '2'.
      IF sy-dbcnt > 0.
        IF NOT it_del_entries[] IS INITIAL.
          CLEAR lv_contents.
          maildata-obj_name  = 'Record Deleted in table ZTS0001'.
          maildata-obj_descr = 'Record Deleted in table ZTS0001'.
          maildata-obj_langu = sy-langu.
       records deleted in ZTS0001 and ZTS_STPGEOLOC
          CLEAR: lv_flag, lv_counter.
          LOOP AT it_zshipto_email.
            CLEAR: it_del_entries, mailtxt.
            LOOP AT it_del_entries ASSIGNING <fs_del_entries>.
            get name of dealer
              SELECT SINGLE name1 FROM kna1
              INTO <fs_del_entries>-name1
              WHERE kunnr = <fs_del_entries>-kunnr.
              IF lv_counter IS INITIAL.
                CONCATENATE: '<p>'
                             'FYI: The ff record/s were deleted in tables'
                             'ZTS0001 and ZTS_STPGEOLOC by user' sy-uname
                             '</p>'
                             INTO lv_contents
                             SEPARATED BY space.
                mailtxt-line = lv_contents.
                APPEND mailtxt.
                CLEAR: mailtxt, lv_contents.
              ENDIF.
              APPEND mailtxt.
              CONCATENATE: '<p>'
                           'Dealer :' <fs_del_entries>-kunnr '-'
                           <fs_del_entries>-name1 '</p>'
                           INTO lv_contents
                           SEPARATED BY space.
              mailtxt-line = lv_contents.
              APPEND mailtxt.
              CLEAR: mailtxt, lv_contents.
              CONCATENATE: '<p>'
                           'Ship-To:' <fs_del_entries>-cdseq '</p>'
                           INTO lv_contents
                           SEPARATED BY space.
              mailtxt-line = lv_contents.
              APPEND mailtxt.
              CLEAR: mailtxt, lv_contents.
              CONCATENATE: '<p>'
                           'Address:' <fs_del_entries>-zaddress '</p>'
                           INTO lv_contents
                           SEPARATED BY space.
              mailtxt-line = lv_contents.
              APPEND mailtxt.
              CLEAR: mailtxt, lv_contents.
              CONCATENATE: '<p>'
                           'Contact person:' <fs_del_entries>-zcperson
                           '</p>'
                           INTO lv_contents
                           SEPARATED BY space.
              mailtxt-line = lv_contents.
              APPEND mailtxt.
              CLEAR: mailtxt, lv_contents.
              CONCATENATE: '<p>'
                           'Contact number:' <fs_del_entries>-zcnumber
                           '</p>'
                           INTO lv_contents
                           SEPARATED BY space.
              mailtxt-line = lv_contents.
              APPEND mailtxt.
              CLEAR: mailtxt, lv_contents.
              lv_counter = 1.
            ENDLOOP.
            APPEND mailtxt.
            mailrec-receiver = it_zshipto_email-zemail.
            mailrec-rec_type  = 'U'.
            APPEND mailrec.
            CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
                 EXPORTING
                      document_data              = maildata
                      document_type              = 'HTM'
                      put_in_outbox              = 'X'
                      commit_work                = 'X'
                 TABLES
                     object_header              = mailtxt
                      object_content             = mailtxt
                      receivers                  = mailrec
                 EXCEPTIONS
                      too_many_receivers         = 1
                      document_not_sent          = 2
                      document_type_not_exist    = 3
                      operation_no_authorization = 4
                      parameter_error            = 5
                      x_error                    = 6
                      enqueue_error              = 7
                      OTHERS                     = 8.
            IF sy-subrc <> 0.
              MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
            ENDIF.
            CLEAR:    mailtxt, mailrec, lv_counter.
            REFRESH:  mailtxt, mailrec.
          ENDLOOP.
        ENDIF.
    Message was edited by: viraylab

    Hi,
    Check this...
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5931ff64-0a01-0010-2bb7-ff2f9a6165a0
    Regards
    vijay

  • Decimal format to 2 decimal places ????

    Hello Everyone,
    I have created a web dynpro application which to display a report depending on the data given by the BAPI. But there is some issue with the numeric data returned by the BAPI.
    For ex - if the BAPI returns 5.00 the value is displayed in the report as 5.
    I want uniform decimal values till 2 decimal places. For example 5 shd come as 5.00, 2.1 shd come as 2.10 etc.
    I searched SDN abt this, and found many threads relating to this.
    I tried using decimal format, creating a simple dictinary type, but using all this what happens is the value basically changes to a string format, this implies that the value is displayed in the table as "left-aligned".
    Where- as we need the decimal numeric values to be right-aligned.
    Any thoughts how to achieve this.
    Please correct me if I have missed out on anything.
    Thanks,
    Samta

    Hi,
    From wat i understood.. u have a attribute coming from BAPI.. which you want to display with two decimal places,,
    In this case.. assuming it is coming with 2 decimal places from the backend..  create a value node.. inside the node which contains the output data. set its carinality to 1..1 .. create a value attribute of type big decimal in it.. or probably string.. if there is an issue in displaying BigDecimal directly..
    map this new attribute to the necessary column in the table..
    BigDecimal value = new BigDecimal("the actual value in string or long").setScale(2);
    assign this to the value attribute created..
    (If alignment is the problem.. set the column 's textview property halign to right.. and layout as block or paragraph.. )
    Regards
    Bharathwaj
    Message was edited by:
            Bharathwaj R

  • Stop dreamweaver using split view

    Hi all,
    I love the fact that dreamweaver CS4 shows included files such as a style sheet when I open the main HTML file, anyone know how to stop dreamweaver using split view when I click on one of these included files? I never use / like split view.
    Thanks

    That's correct Brad.
    Thanks for the tips, especially right clicking to open as a separate file!
    I never noticed that it was only splitting the screen when I was in design view.
    I do actually use code view more than anything, I write PHP in dreamweaver and that is why I was getting annoyed, sometimes I can have several files included in a single PHP page, and flicking through them was getting annoying if the screen auto split .
    I actually discovered vertical split view and I like it a lot! Works really well on my dual monitor setup;code view on the left monitor, design view on the right.
    Still think there should be an option to disable auto split.

  • I'm trying to enter a decimal. How do I get it to stop rounding to a whole number?

    I have to enter in data as a decimal, but it rounds it up or down everytime I move to the next cell.  How do I get it to stop rounding automatically?

    select the the column of cells and apply the formatting you want using the cells inspector:
    To open the inspector select the menu item "View > Show Inspector"

  • How can I create accurate decimal dimensions when creating a new document or using the art board in Illustrator CS6? When I type in a number with a decimal, it automatically rounds the number up.

    How can I create accurate decimal dimensions when creating a new document or using the art board in Illustrator CS6? When I type in a number with a decimal, it automatically rounds the number up.

    For my part you are welcome, sdowers.
    Unfortunately, the uncertainty arising from the rounding has been up several times here in this forum.
    I just came to remember a warning that needs to be given:
    The rounding of the representation of a numerical value may be harmless in itself, but if you use it for any operation that changes the value, such as multiplication or whatever, things will go wrong because the operation will be made on the basis of the rounded value instead of the true value. So, as in your first case in post #2, 39.625 rounded to 39.63 will become 79.26 instead of 79.25.

  • Rounding to 2 decimal places WITHOUT using any formatting class

    Hello
    I'm trying to round a number (double) to 2 decimal places without using any of the formatting class like (DecimalFormat or Math.Round and BigDecimal). Is it possible to do it by just using typecast?

    OP:
    BigDecimal is not a formatting class. Math.round isn't a class at all.
    Typecasting doesn't really do that sort of thing at all (unless you count dropping fractional components when casting to an integer type).
    double holds values in binary format, so it's basically impossible to round to decimal values meaningfully.
    Chuck:
    I thought that BigDecimal supported arbitrary decimal precision, so one doesn't have to do that sort of thing....?

  • How to stop the spinning ball/pizza that is stalling repairs to project on imovie 09? on macosx10.5.8 using iomega and superspeed ext h.d. as storage for the events and projects archive of a wedding video that has had audio sync problems on all share form

    How to stop the spinning ball/pizza that is stalling repairs to project on imovie 09? on macosx10.5.8 using iomega and superspeed ext h.d. as storage for the events and projects archive of a wedding video that has had audio sync problems on all share formats (iDVD, mp4, and last of all iTunes). The project label now carries signal with yellow triangled exclamation “i tunes out of date”.
    To solve the sync problem I’m following advice and detaching sound from all of the 100 or so short clips.  This operation has been stalled by the spinning ball. Shut down restart has not helped.
    The Project is mounted from Iomega and superspeed ext hd connected to imovie09 on macosx 10.5.8.
    What to do to resume repairs to the audio sync problem and so successfully share for youtube upload?

    How to stop the spinning ball/pizza that is stalling repairs to project on imovie 09? on macosx10.5.8 using iomega and superspeed ext h.d. as storage for the events and projects archive of a wedding video that has had audio sync problems on all share formats (iDVD, mp4, and last of all iTunes). The project label now carries signal with yellow triangled exclamation “i tunes out of date”.
    To solve the sync problem I’m following advice and detaching sound from all of the 100 or so short clips.  This operation has been stalled by the spinning ball. Shut down restart has not helped.
    The Project is mounted from Iomega and superspeed ext hd connected to imovie09 on macosx 10.5.8.
    What to do to resume repairs to the audio sync problem and so successfully share for youtube upload?

  • How do I round calculations to two decimal places (form-wide)

    Hi,
    I've created an order form where customers input the quantity of product they want to order and the form outputs the total due (including shipping and sales tax). Depending on user input, the resulting total sometimes contains more than two decimal places. How do I round calculations to two decimal places? Is there a way to do this form-wide?
    I'm new at using Acrobat for calculations. Any help would be greatly appreciated! Thanks...

    The above will affect the displayed value not the actual value of the field nor its value when accessed in another computation. This behavior may cause an error of 1 cent or more in the grand total or sales tax computation. If you want the the value and displayed value to be the same value you can use the following Validation script:
    event.value = util.scand("%,1 0.2f", event.value);

  • How do i use conditional formatting to edit the color of other selected other cells?

    I have been playing around with the conditional formatting feature of Numbers, I have figured out how to change font and background color of the cell i am working with.
    However what i am looking to do is apply a background color formatting to another cell (i.e. F2) if conditions are met in (B2).
    the end game is this,
    I want to make a column of check boxes, and using contional formating i want adject cells to change color (I.e. the example above: if (B2) is a check box, then when unchecked the reffered Cell (F2) does nothing, but when check the color of (F2) changes)
    I can make this happen with Logic equations, the give (i.e. F2) some letter or number value, then using conditional formats i can have the color change. but this leaves that particular cell useless to me (i.e. F2) I am not free to enter or edit text in that cell. (i.e. =IF(B2=TRUE,"Paid","Due") ----> then add a conditional statement that chages color when the value is either "Paid" or "Due")
    How do i have F2 change color, when B2 is checked and still retain the ability to enter information (or potential have another formula) in F2? (The Cell is not used up by "Paid" or  "Due" it is editable just like any other cell)
    is there anyway to change cell characteristics like font, color, and background color inside a formula, because in that way i would be able build it manually
    i tried using the formula editor inside the conditional format pane, but the only infor it will allow me to retain is one partictular cell. i cannot add modifiers like "+" or "=" or anything else. what is that space used for then?
    thanks for anyones help

    MC,
    You can do what you want in Numbers. It requires an auxiliary column and it's a bit tedious to set up because conditional formatting by comparison to another cell isn't relative, so each cell has to be programmed individually with no option to Paste or Fill to other cells in a range.
    For explanation purposes, let's say your checkbox is A2, your cell to be conditionally formatted is B2, and your auxiliary cell is  C2. To have the format of B2 determined by the checkbox status in A2, you will:
    1. In C2 write: =IF(A, B, " ") The " " is any string or value that you don't expect to encounter in B normally, and using the space character means you don't have to worry about having it visible if C is in View.
    2. In B2 use Conditional Format: "Equal To" cell C2 and set your text and fill attributes to be used when the box in A is checked.
    That's it. Do that for every cell in the range.
    Jerry

  • How to stop iTunes creating a new library on my hard drive when it can't find the one I have created and told it to use on an external drive?

    I have quite alot of music etc so to save hard drive space I have created my iTunes library on an external hard drive. If I ever accidentaly open iTunes when that external hard drive isn't attached iTunes makes a whole new library from scratch on my computers hard drive. I find this highly frustrating as I often open Itunes to find no music as it have changed librarys and I have to re-load my actual library: very frustraiting and time consuming.
    I would like to know if it is possible to lock iTunes some how to stop it from changing folders when it can'f find the library, or atleast give me a warning that it can't find the library before creating a whole new one????

    Tunes works through a database file which has a list of your tracks.  When you click on a track it looks up in the database which file it needs to play, then plays the file.  If something breaks this link then you get !  The two main ways to get ! are to move a file from where iTunes expects it to be, or to delete it altogether.  I don't know which has happened in your case.  You can try using Spotlight to find a file for the one referred to in a broken link.  If the files have been moved then they need to be moved back.  If they were deleted completely you will have to restore them from a backup or download them again from the iTunes Store and rebuild your library.

Maybe you are looking for

  • Need help with search function in my program

    Hello all, some of you may remeber me from my previous inventory programs. Well I am finally on my last one and I need to add a search option to the code. Here is the class that will contain that option. import java.util.*; import javax.swing.*; impo

  • Safari video out to TV

    I don't know if this has been documented or not but apparently any video that will play in Safari will play out to your TV. I discovered this by accident. I was using the YouTube app (connected to my TV) to play some videos and couldn't find a partic

  • Save file as text file

    i will try this again. i have a table with lots of fields. one field has event type i would like to count event type and save it to a text file with the heading of type of event, say "accidents", "alarms". i only want the total number and to be displ

  • MC50 - Dead Stock Report

    Good day to all. We use the MC50 report to identify obsolete stock. We use a one plant system with various storage locations dispersed throughout the geographical area of our company. The problem we have is that the MC50 report as input parameters re

  • Better slideshow product out there?

    Just looking for a little advice from those who have working with picutes and other software as well. I'm new to saving and displaying pictures on my computer. I bought PS3, thinking it was the best software out there in saving and presenting picture