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....

Similar Messages

  • 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)

  • Multilist box with decimal format

    I defined a global array of cluster "Test Results" with all the parameters I needed to log and created a user event which triggers when the data needs to be logged. Though I created the pressure flow rate and vacuum flow rate as a double when I write it to list box or a .csv file I see the rounded value. I tried %d or %f instead %s but still I get a rounded value. But when I checked my global variable "Test Results"those parameters are double. Any help is appreciated.
    Thanks
    Solved!
    Go to Solution.
    Attachments:
    atp.jpg ‏112 KB

    romesh, remove the . in the format specifier or place a value after the .
    the format specifier %.f will be read as %.0f which will have no places after the decimal point.  If you need 2 places use %.2f.  That should fix the problem. 
    Troy.
    Troy

  • How to use Time Format with decimal to calculate races cars. ss,ddd ?

    In excell there are a user defined format MM:SS.000 very convenient to use in races with decimal precision.
    So in a race car we can have lap times like
    Car 1 - 1:23.234
    Car 2 - 1:23.132
    so the diference can be calculate and the result is 0.102.
    But in NUMBERS therer are no way to use with this precision.
    Somebidy has the same problem?

    Hi hi ni,
    I'm not sure if I understood you, but you can try doing this.
    Create a variable for 0calyear. The user will input the year.
    In the report you use this:
    0calmonth - NumberOfEmployeesKF
    If the user enters 2008, then it will show:
    01.2008 - nnn
    02.2008 - xxx
    03.2008 - zzz
    Hope this helps.
    Regards,
    Diego

  • Decimal format time value to convert into time (hr:min:sec)value in a graph

    I need to develop a graph in WAD, in BW7. In the graph the value must be showed as HR:MIN:SEC, which I cannot get it right.
    The keyfigure value  carries the duration(hr:min:sec) in decimal format.  In the query, I use this keyfigure for calculation. To get the time broadcasted for a week range. I get the total duration (say 507835.000). Now I need to convert this value back to hr:min:sec. I use the below formulas to get the hr, min, sec.
    D = 507835
    Val1 = D/3600
    Val2 = Frac(val1)
    Val3 = Val2 * 60
    Val4 = frac(Val3) * 60
    Hr = Val1 – Val2
    Min =  Val3 – frac(Val3)
    Sec =  Val4
    In another formula in the query I add Hr + Min/100 + Sec/10000 to get hr.minsec format.
    When I do an average on count of weeks,  this doesn’t round off correctly.
    I tried to also use the Data function TIME() which when the time is > 24 hrs changes the value.
    Lets say if it is 39:00:00, it shows value as 15:00:00 instead of keeping the value 39:00:00.
    When I used this value in the graph it did not show the HR:MIN:SEC values in the value axis instead  it showed 0.0, 0.1,….1.0. Bcoz of this the graph is blank.
    Can anybody help me to resolve this problem.
    Thanks alot
    Anima

    I checked SU01 and didn't see anything there to customize...
    In my workstation, control panel / regional and languages settings / tab regional Options / customize; my time format is HH:mm:ss; the HH has to be in capital letter to display the time in 24 hour...
    but this is strange anyway... are you reporting with web frontend or excel?

  • Trouble with decimal delimiter in VC

    Hi Guys!
    I've got quite strange problem.
    Visual Composer seems to incorrectly deal with decimal delimiters.
    Just a quick exapmle.
    I'm trying to implement incoming invoice creation in VC. To post invoice I use standard BAPI (BAPI_INCOMINGINVOICE_CREATE). To get purchase order information I use standard BAPI (BAPI_PO_GETDETAILS). [Here is|http://www.dennisk.org/tmp/SAP/po_sap.jpg] how purchase order looks like in SAP. [Here's|http://www.dennisk.org/tmp/SAP/inv_creation_port.jpg] how invoice creation screen looks like in Internet Explorer.
    After deployment I was able to post invoice, but there was no financial information (gross value, net prices, etc.), [Here's screenshot|http://www.dennisk.org/tmp/SAP/inv_created_sap.jpg] . Then I noticed, that if invoice contains only integer number (without any digits after decimal point) - invoice can be posted with that financial info.
    Then I tried at some custom model to do something with NET_PRICE field, I entered formula for that field ( NVAL(NSTR(@NET_PRICE,'10,2')) ). After that I was able to transfer net price, but it was rounded (no decimal digits again). [Here's screenshot|http://www.dennisk.org/tmp/SAP/cust_bapi_result_formula.jpg].
    Then I tried to enter another formula for GROS_VALUE ( NVAL(REPLACE(@GROS_VALUE, '.', ',')) ). After that gross value was passed, but it was wrong (from 2542.37 it became 254237.00) [Here's screenshot|http://www.dennisk.org/tmp/SAP/vc_cust_module2.jpg].
    The main question is - what is happening with decimal delimiters in VC and how to make them working?
    One more things. This behavior  occurs even if data is transfered directly from BAPI to BAPI in VC.
    Thanks in advance for help and support!
    Regards,
    DK

    Hi Denis,
    this is a known issue, please check these threads:
    [Thousands separator|Thousands separator]
    [Is it possible to configure thousands and decimal separator|Is it possible to configure thousands and decimal separator]
    [Numeric Format Error|Numeric Format Error]
    [Re: configuring Decimal places|Re: configuring Decimal places]
    Best Regards,
    Marcel

  • Key figure Date in Decimal format

    Hi all,
       I have a key figure 0CPR_ACFR_K  (Date) which is in Decimal format.
       Data in PSA for the particular field was like this '07102008'
       but after that it is changing to 7327.98  that is in decimal format.
       But i dont want this to happen ie. it should not get converted to Decimal or
       i want to convert the decimal value again to the equivalent date.
       pls help in this.

    Hi  jean liker,
    It will get converted due to its properties. If you want to use this particular object as keyfigure, you can create a variable with processing type replacement path and use. Its better to maintain as char.
    [Replacement Path: Replacement with a Characteristic Value|http://help.sap.com/saphelp_nw04/helpdata/en/03/6ba03cc24efd1de10000000a114084/frameset.htm]
    Hope it Helps
    Srini

  • 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

  • Convert a column in Numbers that is currently in HH:MM format to decimal format.

    I need to Convert a column in Numbers that is currently in HH:MM format to decimal format.  IE 6:30 to 6.5

    Rj,
    There are two possibilities here. Your HH:MM could be a Date/Time value or a Duration.
    Let's assume your data is in Column A.
    If it's a Date/Time value, do the conversion with the expression:
    =TIMEVALUE(A) * 24
    If it's a Duration value, do the conversion with the expression:
    =DUR2HOURS(A)
    In both cases, remember to Format the result to Number with at least one decimal place.
    Regareds,
    Jerry

  • Time format to Decimal format

    Hi all
    Does anyone know how to format time format to decimal number?
    Eg: '10:21' in HH24:MI to 10.21
    '21:09' to 21.09
    Thanks in Advance
    Prash

    Since you just want to replace the colon with a period in a string, just use the string replace function:
    select replace('10:21',':','.') from dual;However if you convert this to a number, then as Boneist said it's not really comparable to the time portion of a date as 21 minutes is not 21/100 of an hour but is rather .35 hours (21/60). You won't be able to use this decimalized format as a meaningful number, nor will you be able to do any sort of date based arithmatic on it.
    You may be better off converting your string to date, then into a number via some date math:
    with sample_data as (select to_date('11:21','HH24:MI') dt from dual)
    select dt, (dt - trunc(dt))*24 from sample_data;Edited by: Sentinel on Nov 10, 2008 9:40 AM

  • Rounding a decimal to 1 up

    Hi All ,
    I need help in rounding a decimal to intezer up by one value ,
    i.e 1.001 to rounded to 2 .
    Thanks and regards
    vinay

    Hi,
    plz try ROUND function module.
    data input type p decimals 3 value '1.001'.
    data output type i.
    CALL FUNCTION 'ROUND'
      EXPORTING
       DECIMALS            = 0
        input               = input
       SIGN                = '+'
    IMPORTING
       OUTPUT              = output
    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.
    write: output.
    thanx .
    Edited by: Dhanashri Pawar on Sep 22, 2008 9:21 AM

  • Rounding when using format-currency

    Hi all,
    We're using format-currency in several places in out reports. I.e.
    <?format-currency:ssLfBonusAmountContributing;'EUR';'true'?>
    When using this formatting we always get the value with 2 decimals.
    Is it possible to round and display without decimals?
    Regards,
    Hakan

    Hi all,
    Haven't anyone come across this issue, with currency-format and display value without decimals?
    I know that I can use number-format, but this is not then first option.
    Regards,
    Hakan

  • So What Now with Help Formats ???

    Well... the launch of Vista and the death of Winhelp has
    really shafted us... and I'm sure a lot of others too. Current
    situation as I understand it is :
    1) Winhelp is dead.
    2) HTML Help is supported but is functionally inferior in the
    following ways :
    - Window position cannot be specified as a percentage of the
    screen (pixels only) which is awkward for secondary windows as we
    need to support everything from 1024x768 to 1920x1280.
    - Context sensitive help support is dreadful compared to
    winhelp - no formatted text, bullets, graphics, hyperlinks, etc...
    - Microsoft refuse to allow CHM files to be launched over a
    network so a server install is out (without a naughty registry
    hack).
    3) Webhelp is supported but rumoured to be on the way out in
    terms of Robohelp support. Is this true ? Its also extremely clunky
    to ship with software due to number of files and, AFAICS, offers no
    context sensitive help functionality. I guess we could get round
    the former by using .MHT files but reasonable support for context
    sensitive help is a must.
    4) The Windows Vista Help directory seems to use 'h1s' files.
    What on earth is this ? For sure Vista has nicely formatted Context
    Sensitive Help but how ? Is this the new, much publicised MS Help
    format ?
    Basically, we need a sensible single file help system for the
    app and context sensitive help with hyperlinks & formatting.
    Anybody have suggestions on what the trend is here - is there even
    a single format solution for what must be a common applications
    requirement ?
    Are Adobe planning their own Winhelp support now that MS have
    ditched it ?
    Are MS planning a new Help System ?
    Thanks,
    Iain.

    I find it fascinating that Microsoft distributes winhelp.exe
    (16-bit
    WinHelp) as part of Vista but stubbornly refuses to
    distribute winhlp32.exe
    (32-bit WinHelp). Apparently Microsoft still needs/wants to
    use WinHelp
    popups so they're keeping the 16-bit WinHelp executable as
    part of Vista.
    So now here's my question... Robohelp has its own .dll
    (RoboEx32.dll) that
    it allows us to distribute. My understanding is that this is
    what allows us
    to have the tripane view. Having been mostly away from help
    development for
    the last several years but about to enter the fray again,
    what happens if I
    develop a RoboHelp Help2000 project and load project.hlp,
    project.cnt and
    the RoboHelp .dll file onto a Vista machine (which only has
    winhelp.exe)??
    Does this work?
    Thanks
    Mike
    "Tamilyrn" <[email protected]> wrote in
    message
    news:[email protected]...
    > Well... the launch of Vista and the death of Winhelp has
    really shafted
    us...
    > and I'm sure a lot of others too. Current situation as I
    understand it is
    >
    > 1) Winhelp is dead.
    >
    > 2) HTML Help is supported but is functionally inferior
    in the following
    ways :
    > - Window position cannot be specified as a percentage of
    the screen
    (pixels
    > only) which is awkward for secondary windows as we need
    to support
    everything
    > from 1024x768 to 1920x1280.
    > - Context sensitive help support is dreadful compared to
    winhelp - no
    > formatted text, bullets, graphics, hyperlinks, etc...
    > - Microsoft refuse to allow CHM files to be launched
    over a network so a
    > server install is out (without a naughty registry hack).
    >
    > 3) Webhelp is supported but rumoured to be on the way
    out in terms of
    Robohelp
    > support. Is this true ? Its also extremely clunky to
    ship with software
    due to
    > number of files and, AFAICS, offers no context sensitive
    help
    functionality. I
    > guess we could get round the former by using .MHT files
    but reasonable
    support
    > for context sensitive help is a must.
    >
    > 4) The Windows Vista Help directory seems to use 'h1s'
    files. What on
    earth is
    > this ? For sure Vista has nicely formatted Context
    Sensitive Help but how
    ? Is
    > this the new, much publicised MS Help format ?
    >
    > Basically, we need a sensible single file help system
    for the app and
    context
    > sensitive help with hyperlinks & formatting. Anybody
    have suggestions on
    what
    > the trend is here - is there even a single format
    solution for what must
    be a
    > common applications requirement ?
    >
    > Are Adobe planning their own Winhelp support now that MS
    have ditched it
    > Are MS planning a new Help System ?
    >
    > Thanks,
    > Iain.
    >
    >
    >

  • DVD Studio Pro crashes when accessing folders with mixed formats

    DVD Studio Pro 4 on Mac Book Pro OSX 10.6.8
    Program crashes whenever accessing my movies directory. It contains mostly HD content in MOV format. There are some MP4 and M4V in there too.
    To check this I copied an MOV, MP4, and M4V into a separate directory. I added this folder to the Video tab of the Palette in DVDSP and same crash occurs until I remove all but MOV content.
    Project setting is 1920 x 1080 HD. I have successfully imported several assets in MOV format.
    My question is why would DVD Studio Pro crash just because it is pointed to a directory with mixed formats? Would it not just ignore to incorrect formats and move on? Why the crash if I am not trying to import them?

    I was going to let this go doc, but....
    I discovered the crash by accident while doing Ripple Current training - yes I am a complete DVD SP newbie! Anyway my story: Oh look! There is an icon pointing at my Movies directory in the Video tab. Gee thats cool lets see what is in it. Ooooh s&*t the program just crashed! That can't be right, lets just try it again. Now thats just wrong! I'll beat this thing so lets experiment. Lo and behold its a mixed format problem. Why doesn't DVD SP just ignore any unrecognized formats like any other program? Hmm, being the newbie I am, and there was no hint in the Ripple training, I would ask the docs on the Apple forum. They will know why and what to do!
    DVD SP seemingly by default maps my Movies directory. My Movies directory has multiple formats in it from years of use. I have movies for my iPhone, iPad, movies for Vimeo and iTunes, as well as other distribution formats in the same directory. I also have been experimenting with different codecs. My Movies directory has been used as an Internet distribution point. So please excuse me if I did not clean out my Movies directory before launching DVD SP! Little did I know this would even happen. If I could "unmap" this selection permanently I would - do you know how to do this? So far I cannot find any preference for it.
    In a round-about way you got there, however so did I on my own - isolate the project to its own directory and NEVER pick on the "Movies" icon. I am not satisfied since it would be really nice to block this from ever happening again. God forbid an incorrect format should ever sneak into the sacred project directory "sorry but DVD SP and incorrect formats don't play nicely", so stop doing that!

  • Math.round with checkbox for tax

    I have a form that needs to calculate sales tax. If it ships to California, then tax is applied.
    I have been attempting to cobble together a Boolean JavaScript in Acrobat v8 (on a Mac) using Math.round(). No luck, it always defaults to else. I have searched this forum, planetpdf, bought Padlova's Acrobat Forms book, and just have been stonewalled on this issue.
    I have a series of items that SubTotal - ItemTotal.1, ItemTotal.2, ItemTotal.3 using the simplified Value is menu.
    California tax is calculated with (Tax * SubTotal) * 0.0725, where Tax is a checkbox with a Mouseup value of 1. When the checkbox is active, the tax is added, otherwise the tax value is zero.
    As near as I can tell looking at the State Board of Equalizations tax tables, Acrobats default rounding is displaying the correct amount of tax.
    Is there any reason I shouldnt leave this as it stands, as opposed to more research into the correct syntax for Math.round() with a checkbox variable?

    Interesting - but exactly the sort of thing a programmer hates. It
    gives a huge table, but it doesn't give the exact rules needed to
    actually write legal code.
    There isn't a generic standard to use. In fact, in some states, the
    rule changed. For example, in 2005, Ohio changed to "The computation
    shall be carried out to three decimal places. If the result is a
    fractional amount of a cent, the calculated tax shall be rounded to a
    whole cent using a method that rounds up to the next cent whenever the
    third decimal place is greater than four. A vendor may elect to
    compute the tax due on a transaction on an item or an invoice basis."
    Instead of "always rounding up in any case where the tax calculation
    yielded any fractional amount over a whole cent".
    But you say "rounds up". Let's test that with the table. $100 is a
    good starting point. 7.75% of $100 is exactly $7.75, so no rounding is
    needed. This matches the table, which says that amounts over $99.93
    pay $7.75 tax. So, what about $99.93? Calculated exactly, 7.75% is
    $7.744575. If this were simply rounded up, the tax would be $7.75.
    This suggests it is actually rounded to the closest, and might be the
    same as the new Ohio rule. Or some variation on it.
    Interestingly, there is a California sales tax calculator on
    http://www.csgnetwork.com/salestaxcalc.html, and it seems to match the
    table. They do offer a JavaScript calculator for license, and given
    that it runs to something like 60 lines of code, this may be worth
    considering, as reimplementing it (without copying) sounds hard work.
    Aandi Inston

Maybe you are looking for

  • Multiple Desktops Tips

    Once you have created a number of, any number of Desktops: 1. You can move across them & back again by  Ctrl+Win <--- OR ---> 2. Hit the Task view icon; now you can move items, Universal APPs, browser windows, word docs, etc. (open windows) from one

  • Change layout button in ALV Grids

    Hi Experts, I have displayed 2 ALV grids in a single screen using OOPS concepts and I have activated the Save Layout option for both the Lists. Now whenever I will save the layout for the 1st list then automatically it is taken into consideration for

  • ATV Airplay (audio only) starts then stops

    Pretty much what the subject says. I'll start audio playback from iTunes 11.0.4 to 3rd-gen ATV that is running latest OS 5.2.1. Music plays for 1-2 seconds then stops. Sometimes I can start it again, but it will stop. Usually I can't start it again.

  • URGENT : why get_file_name does not work in forms 9i ?

    Hi all We use oracle 9i 9.2 Developer Suite in our organization ; and I am developing a forms 9i application which includes a get_file_name(save_file) built-in in a when-button-pressed trigger of a button. The problem is that when I run the applicati

  • No clips in iMovie 09 windows

    My iMovie 09 windows show up, but there is no clip in them. I cannot scroll up or down. But my movie is still playing well.