Precision problem with float

Hi,
I have class with an amount variable whose type is float. If a value like 999999.99 is set to this variable, when I try to display this in JSP, the precision is lost. It displays 1000000. But my requirement is to print 999999.99. Is there any to solve this problem? The constraint to this prioblem is I can't change the data type of this variable. (Actually this class is generated through Castor. The xsd type is float. I am not supposed to change the XSD).
Please advise.

There's nothing to be done about it if you can't change the data type. See for yourself:    System.out.println(999999.99F == 1000000F);  // yep, they are equalBlame the person who decided that you should use float.

Similar Messages

  • Problem with Float.toString

    Hi,
    I have a small problem with wrapper class Float.
    For example
    float f = 99999999999999999f;
    f.toString(); returns a mentioned in the api doc: 9.9999999999999999E16
    while I wanted the original 17 times a 9,
    how can I achieve this??
    THX

    I tried to use the DecimalFormat class with the patter 17 * #, but the string it prints is no longer the same as in the original Float (17 * 9), now I get 17 chars but they are no all 9

  • Problem with floated elements in IE5.5

    I've apparently got a problem with a right sidebar float
    being dropped in a primitive version of IE and I can't figure out a
    remedy, as none are suggested in dwcs3's browser compatibility
    function. The site is lindafarronknapp.com... if anyone has any
    suggestions I would more than appreciate it...

    Thank you for the replies. What was happening is that the other audio files were being onverted by PPPro. This one was not. I moved the file to the desktop and once again placed it into the project. This time the yellow conversion line on the bottom right corner went to work and it works fine. It was some type of glitch with that one file. Thanks again. Roman

  • Smart Forms : problem with Float Variable

    Hi  Expert,
       I have a probelm with Float variable. In my smart forms one fields of table QAMV contain value like 8.0000000000000000E+01.
    I have to remove the exponent and display value like 80.
    I have tried wa_qamv-sollwert(E10.4).. but it not working.
    Can U suggest me some solution.
    Regards
    Swati.
    Edited by: Swati Namdev on Apr 27, 2010 12:19 PM

    Hi,
    Please follow the steps.
    1. In your smart form create a variable w_val ,, type,, associate type -->  CHAR10
    2. Now write a code, jsut above your node where u wud like to get this value... For this Create -> Flow Logic -> Program Lines.. Now you have editor..
    3. In input parameters , put i_tab-QAMV.. and in output parameter put w_val... and Code like below
    CALL FUNCTION 'MD_CONV_QUANTITY_FLOAT_TO_PACK'
      EXPORTING
        iv_menge       = i_tab-qamv
      IMPORTING
        EV_MENGE       = w_val.
    4. Now grag and drop this w_val from global data field list...your this w_val will have the rounded value.. Pls try this and check..   It will work.
    Regards,
    Lokesh.
    Edited by: Lokesh Tarey on Apr 27, 2010 9:28 AM

  • Problem with floating point precision

    Hello!
    I need to store in a variable a number like this 1234512345.123412345.
    But when I store it on a double or long double... it gets truncated to 1234512345.123412... only six decimals?
    What can I do??
    Thanks!

    If you are going to use the BigDecimal class, it is worth bearing in mind a tip that was passed on to me from georgemc. If you create the BigDecimal class instances using the constructor that accepts a String as input, then you can easily specify how many digits should follow the decimal point.

  • Important Problem with floating toolbar !

    Hi all!
    I developed a plug-in using Acrobat 8 SDK. When I start acrobat 9.0,
    click any floating toolbar on which all tool buttons have been expanded,acrobat 9 will exist,but acrobat 8 is OK. This situation only happens when floating toolbar has some expandable tool buttons and all buttons have been expanded, and acrobat 9.0 starts without openning a PDF.
    I debuged my plug-in, stack overflow happened in acrobat.exe!
    How to solve this problem? Thanks all!

    I would start by using the debugger to try to find where the crash is taking place. I wold ensure that all of my code is properly wrapped with DURING/HANDLER blocks.
    If you are still having problems, I'll submit a formal support request to Adobe Developer Support.

  • Access db: problem with float numbers if access isn't installed

    hi all,
    i wrote a simple application to store/retrieve float values into/from an access db.
    i tried it on my computer (with ms access installed) and i could store float values (ie 136.5), but when i tried my application (copying all classes and the db) on another machine without ms-access, i couldn't store float values, only int (ie 1365.0).
    the column "price" in the db is set as float with 1 decimal number, and there are other columns set as string, with no problem.
    anyone could help me?
    should i install access into the second machine too?
    thanks
    sandro

    Could it have something to do that on one machine '.' is interpreted as a decimal point, but on the other machine it is interpreted as the , you use in e.g. 1,000 (=1000).
    I would check that both macines use the same Regional Settings (in the control panel).
    Do you use any of the java.text.xxxFormat classes?

  • Problem with Float - round down error

    I have to save in database (MySql) amount which is passed by user. For instance user writes 99999999999. But Float.parseFloat(request.getParameter("amoUnit")) returns value 9.9999998E10 . When I save this value in database I receive 99999998000.00. I want to have in database exactly what the user has written. Should I use differen data type? Thanks in advance.

    leonkaP wrote:
    ... I want to have in database exactly what the user has written. Should I use differen data type? Yes.
    If you want more precision than float, use double.
    If you want exact precision, use BigDecimal.

  • Precision Problem with CFQUERY

    I have a column in Oracle which is a Number with precision
    10, and scale 4.
    Everytime I select anything from there from CF, it is
    displaying all 4 decimals.
    Say the number "1" is in one record, "2.2" is in the second
    record, "3.0003" is in the third.
    when I do a select all in a cfquery, I get:
    1.0000
    2.2000
    3.0003
    but if I were to select it in SQLPLUS, I get:
    1
    2.2
    3.003
    which is the result I desire. Why is Cold fusion adding zeros
    to the cfquery? And how can I fix this?
    Thanks,
    boybles

    Use
    #val(your_col)# to display the result as you desire in the
    output. It will "convert" your numeric "string" back to a number
    and drop the trailing zeros.
    Phil

  • Problems with float

    hi,
    Im using float values to represent the price of products in a program. When a user selects a number of products to buy the total value of all the goods is shown, by adding all the float values together. the problem is that when i add all the floats i sometimes get a value greater than 2 signficant places:
    e.g.
    total = 23.34234
    when i really only want
    total = 23.34
    Is there any way of restricting the units shown after the decimal place or is there a better way to represent the price of the produts?

    is there a better way to represent the price of the produts?Yes, use an integral type (e.g. int) to represent the price in pence/cents/gopiks/whatever-is-your-smallest-unit. Binary floating point numbers only approximate most decimal numbers, so they will give you much grief. As a heavyweight alternative you might consider BigDecimal.
    Edna's suggestion is the correct way to format floating-point numbers for display.

  • Problem with floating point numbers

    Hi Experts,
    I am accepting two float values thru a method :- amount and tenure.
    Now wat i want to do is
    target = amount / ( tenure * 12 );
    but result target is not what it supposed to be. For example:-
    if amount = Rs. 15 00 000.0 and tenure = 3 yrs, target amount should be 5 00 000. but it is coming 41666 sumthing.
    How should I code this?
    Pls help,
    regards,
    Amey

    Hi,
    I am accepting two float values thru a method :- amount and tenure.
    Now wat i want to do is
    target = amount / ( tenure * 12 );
    but result target is not what it supposed to be. For example:-
    if amount = Rs. 15 00 000.0 and tenure = 3 yrs, target amount should be 5 00 000. but it is coming 41666 sumthing.
    How should I code this?
    I dont see any error in calculation,
    15 00 000.0 / 36 is perfecctly 41666 sumthing
    how can you expect this to be 5 00 000?
    If you want that change your calculation from
    target = amount / tenure ;
    Regards
    Ayyapparaj

  • Precision problem with illustrator CS5

    Hello,
    We have several licences of illustrator CS5 bought at the same time. When we import the same DXF or DWG file in different brand new computers (windows 7)
    equipped with CS5, on some of them we retrieve the perfect dimensions (for example 100mmX 50mm for a rectangle) and on some others  the dims are not correct (100.189 X 50.094).
    Please, have you got an idea of how to correct that or what must we check in the program setup.
    Thank you.
    Thierry

    Thierry,
    Before such drastic measures it may be worth trying to  Move the folder
    When you uninstall and reinstall, you should use the Cleaner Tool in between:
    http://www.adobe.com/support/contact/cscleanertool.html
    Without that, you may keep corrupt preference settings.

  • Problem with float type display

    I have a float number, after bigger than 1E8,
    it will display as 1E8.
    How can I make it to display at 10000000?
    Thanks

    Hi!
    You may use something like:
    import java.text.*;
    double f = 123456789.9876;
    NumberFormat nf = new DecimalFormat("####.####");
    System.out.println(nf.format(f));
    I believe it is a good idea to use double for such numbers, not float.

  • Problem with floating windows CS4

    Since CS4 I don't see a possibility to open all images separatly in floting windows. When I change it at the pull down menu it just does it with the recent pictures as soon as I open a new one (from the desktop) they are "stacked" again.
    There must be a possibility to change that in general.I do work with PS since 8, this seams to be new. Ay ideas ???
    THX

    UNcheck the "Open Documents as Tabs" setting Tab in Photoshop > Preferences > Interface > Panels and Documents >. I've never seen tabbed windows on my machine thanks to that. ;)

  • Stumped on basic problem with floating point math

    I can't figure this out!  It should be sooooo simple. 
    Here is the challenge: 
    I have an incoming time array.  For example:     0, 1, 2, 3, 4, 5, 6, 7, 8, 9
    I want to scale this array by a constant (e.g. multiply by 0.1).  So the resulting array should be:     0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9
    Then I want to calculate the difference between each and every subsequent element in the array.  In this example, the difference should 0.1 between every element.  But my comparison fails. 
    See the example below.  As far as I can see, the resulting boolean should always be TRUE.  But its not.
    But if I remove the scaling operation, then it works ok!
    Please help!
    Solved!
    Go to Solution.

    It has been awhile since smercurio has had a contribution to his retirement fund, but once again you have "discovered" that there is no exact binary representation for 0.1.
    I'd use one of the current "almost equals" comparisons described here:
    http://forums.ni.com/t5/LabVIEW/Darin-s-Weakly-Nugget-2-8-11/m-p/1444262
    And vote for this if you haven't already:
    http://forums.ni.com/t5/LabVIEW-Idea-Exchange/quot-Almost-Equal-quot-functions-for-Float-comparisons...

Maybe you are looking for

  • Time Machine placing multiple disk images on Desktop

    Hi, I have recently set-up a 2TB Time Capsule for one of my clients. Each time Time Machine does an hourly backup - it places a Disk Image icon on the desktop called e.g.'Backup of Anya' - which is basically the sparse disk image mounting from the Ti

  • Generating I-Doc with Payment Method - D

    HI all, I am trying to process direct deposit with the payment method 'D' to generate the I-Doc. SCENARIO - 1: In FBZP, under 'Payment Medium' section, I am using the classic program RFFOEDI1. (here do i need to give value for "KEY IN CODE LINE") F11

  • Missing points, transaction was not recorded on my account but another.

    My father recently went in to buy a new HDTV and was assured by the represenative at the store that the points for the tv would be added to my account, the account we both do our shopping on. I do believe he in fact did purchase the HDTV with the Bes

  • SAP tables for stocks at warehouse level

    Hi Can anyone let me know which are tables for the stocks which are maintained at the warehouse level. sunil

  • Recieving email

    I use mac mail. I also have a .mac account. Recently my email is only current in the .mac account, it does not sync up when I check mail from the dock. Could this problem be related to the recent upgrade to Tiger? Any help would be appreciated. Palle