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.

Similar Messages

  • 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

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

  • Problem with decimal point in Korea and Japan

    Hi all,
    I have one problem with decimal points.
    I need to change in my out put cuurency values as per japan or korea standards.
    Please help me is there any function module for this one.
    program using alv grid display.
    i use write statement but it is not working. Because
    data: L_AMT  type glpca-hsl,
             G_AMT  TYPE CHAR15.
    CURR this value is 'JPY'.
    WRITE L_AMT CURRENCY CURR TO G_AMT.
    here i need to do
    L_AMT = G_AMT.   "" going to runtime error.
    if i taken like
    data: L_AMT  TYPE CHAR15,
             G_AMT  TYPE CHAR15.
    CURR this value is 'JPY'.
    WRITE L_AMT CURRENCY CURR TO G_AMT.   "" it is not working
    Regards
    margani

    Hello,
    This is pretty basic, whenever you've currency & quantity fields you need to pass the corres. reference fields.
    In your case you need to populate the cfieldname & ctabname fields of the FieldCat.
    BR,
    Suhas

  • Problem with Vanishing Point

    hello!
    I've got a problem using Vanishing Point filter in Photoshop CS4. When I load this filter an error message pops saying "The operation could not be completed"
    I attach a screen cap of the error. Somebody can help? thanks.

    I run into this problem with Vanishing Point on about a quarter of the files I run the filter on. I can initially create a grid and do one transform, but the next time I try to run the filter I get the error, "The operation could not be completed". Then the error seems to stay attached to the file. I can run the filter on another file, but even if I close and reopen the file, I still can't run the filter. Even doing Save As and renaming the file doesn't rid it of the error.
    This has been the case since VP was introduced. I'm now on CS4. MacPro Dual-Core, 8GB Ram.
    I've tried changing the memory allocation to 55% with no change.
    I see that this has been addressed before in the Forum with no solution, Chris Cox care to wade in?
    This is a potentially valuable tool if it were implemented better.
    Craig

  • Floating point precision of "Flatten to XML"

    It appears that the "Flatten to XML" function (LV 7.1.1) truncates floating point numbers to 5 decimal places.  This is a rather annoying limitation, since I'm trying to store a relative time in hours, accurate to the second (chosen by a previous coder that I have to be compatible with - otherwise I'd just use seconds).  Is there a workaround to this?  (other than multiplying by some power of 10 before flattening, and dividing after unflattening)
    Jaegen

    Hi Paul and Jaegen,
    I checked our databases and found entries of product suggestions and
    corrective action requests for the behavior of the limited precision
    when flattening to XML. I found an interesting reply from a LabVIEW
    developer on the request for further precision:
    The Flatten To XML primitive puposefully cuts off all numbers at 5
    digits after the decimal. There are 3 main reasons for this:
    Information regarding precision is not propagated on the wire.
    Therefore, there is no real way to know how many significant digits or
    even places past the decimal point is appropriate when data is
    flattened to XML.
    Bloat. If all floating point values printed all of the possible
    decimal digits all of the time, this would provide for some very large
    blocks of XML code.
    Given the arbitrarily complex nature of LabVIEW data, it is
    difficult to provide a method for specifying precision. For example, if
    a user has a cluster of clusters, each of which contain a single,
    double and extended representing various measurements of differing
    accuracy, how can one precision setting be applied to each of these
    values? The user would have to unbundle (and index if an array was
    involved), flatten, concatenate, and then the reverse on the unflatten
    side.
    I suggest that you go ahead and file a new product suggestion by using the "feedback" link on www.ni.com/contact.
    It would be best if you could give some detailed information on how you
    would like LabVIEW to handle different scenarios while getting around
    the above issues.
    Thanks for the feedback!
    - Philip Courtois, Thinkbot Solutions

  • 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 Black Point adjustment

    When making Black Point adjustments (with hot and cold highlights enabled) my photos suddenly turn completely blue. If I hold click the slider button, I can see the photo again as expected.
    I also notice this histogram is empty.
    I have the same problem with both my Nvidia and Radeon graphics cards.
    This problem has started since my upgrade to 10.5.7
    Has anyone else experience this? ...am I doing something wrong?

    I think I have found the problem. For some reason the Black Point values were incrementing in much higher values than before.

  • Problem with Access Point app

    Yesterday I experienced a problem with my internet sharing where it wouldn't start and gave me an error: Connection not shared, Internet sharing isn't currently available
    . I ran across an article on wpcentral.com where they suggested installing the Access Point app from this thread:
    http://discussions.nokia.com/t5/Pool-of-Knowledge/Nokia-Windows-Phone-8-App-Updates/td-p/1640082
    Now I've done that and I see 3 profiles in the app, only 2 are LTE. Activating either of those LTE profiles now gets me an error when trying to internet share that looks like this: Connection not shared, To enable tethering on this device, go to att.com/mywireless or dial 611. When I use the 3g access point profile I get the same message I was getting yesterday.
    At this point I don't think this app is doing anything for me. I dont' use multiple sims, I'm not a world traveller. I also don't know which profile I should be on. I'm clearly in over my head and would like to just take a step back. However, I can't see a way to uninstall the app as it's now in settings. How do I get myself back to where I was yesterday?
    And for bonus points, does anybody know what the original error I was getting means?
    Thanks,
    Joel

    Hi Adrian,
    Yes, I've tried a soft reset to no avail. I've gone to both the AT&T store and the Microsoft store and neither of them have any thoughts on what's going on. At this point I think I will need to replace the hardware since I've not found a solution from anyone.
    Thanks for you help.
    Joel

  • Generic delta has problem with delts pointer time stamp

    Hi All,
    We have generic delta data source with Delte pointer as Time stamp. We have not used any safety limits. We are loading the data to DSO and using Additive delta. But the problem is when delta flag is set, there might be a case where some records still being inserted to table with lower time stamp. These records are not being fetched in next delta.
    We are planning to keep a safety upper limit of 5 min so that those records can not be missed. But we have a doubt as it is a Additive delta duplicate records will be loaded. If we make the delta to 'new status to changed records', it is going to work?? Any other things we have to check when we make this changes??
    Thanks
    Haaris

    Hi
    If you had selected additive delta then you can load data to DSo with addition mode only. No overwrite possible.
    If you want to select new or changed status then you can load to DSO with overwrite mode only.
    Additive or changed delta depends on your requirement because if you want to add data to the DSO then you can go ahead with additive otherwise you have to use DSO with overwrite mode only.
    You can either give safety upper limit or lower limit but if you give safety lower limit then you can only load data to DSO with overwrite mode because there could be some duplicate records.
    Hope it clarifies.
    Regards
    Sadeesh

  • 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

  • Can I implement advanced control algorithm with floating-point computations in Ni 7831R ?

    Hi,
    I plan to use a Ni 7831R to control a MIMO nano-positioning stage with servo rate above 20kHz. The control algorithm is based on robust control design and it is much more complex than PID. it also includes floating-point caculations. Can I implement such algorithm with Ni 7831R?
    By the way, is there any way to expand the FPGA gates number for Ni 7831R? Suppose I run out of the FPGA gates (1M), can I add more FPGA gates by buying some different hardware?
    Thanks
    Jingyan
    Message Edited by Jingyan on 08-22-2006 01:45 PM

    Jingyan,
    as long as there is no GPU core implemented on the FPGA these devices only support integer arithmetic. NI's FPGA targets currently don't contain a GPU core so there is no native floating point arithmetic available.
    Still there are several options to implement floating point arithmetic on your own or to work around this target specific limitation. Here are some links that might help:
    Floating-Point Addition in LabVIEW FPGA
    Multiplying, Dividing and Scaling in LabVIEW FPGA
    The NI 7831R uses an 1M FPGA. If your application requires more gates the NI 7833R (3M) is a good solution.
    I hope that helps,
    Jochen Klier
    National Instruments Germany

  • Intermittent problem with access point (WAP321)

    We hane an intermittent problem with our Wifi access point WAP321. Suddenly, all clients are unable to access Internet, server and local network. The signal is 100%. The message is no internet connection or limited connection (on all device, Iphone, computer, etc.). When I check to Ip configuration, the ip adress have change for loca 169.x.x.x. The only way to resolve is to reboot the access point. (POE).
    It seem that access point don't relay information to rest of network. Strange.
    The access point is connected to a simple unmanaged switch. This switch is connect to router and server. The serveur (Win2008) is the DHCP Server and DNS Server.
    Can you help me to find a solution. ?

    This may be the problem;
    Devices: WAP discovers devices with ASSOC method that don't have an IP
    CSCtz20891
    Description
    Symptom:
    The OnPlus topology will show nodes with no IP address. Devices associated to WAP121/321 VAP/SSID not on the management VLAN will display topology nodes with with no IP address.
    Conditions:
    This occurs when the client associated to the WAP121/321 but is on a VLAN other than the management VLAN. In this case the WAP client information can be collected on the management VLAN, but the clients cannot be ARP/ping to validate.
    Workaround:
    None

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

  • Reflection problems with null pointer exception

    I am having a problem with reflection. I keep getting a NullPointerException and can't figure out why.
    It is happening when I call this:
    ResponseObject result = (ResponseObject)method.invoke(classInstance, argArray);
    I can't figure out what the problem is. I had this reflection working, and then I made some changes to how the argument array was created. In the end, the argarray is the same.
    Any ideas?

    Also, the API for the method class says that a
    NullPointerException is thrown if the object in the
    first argument is null. I have tested for this, and
    it is not null.does it? read again, because giving 'null' as the first argument is perfectly legal. how else would you reflectively invoke a static method, since you might not have an actual instance of the class to pass

Maybe you are looking for