Failure to convert infinite double to BigDecimal

I need to convert double to BigDecimal. But one of the double values is infinite and is not converted into the BigDecimal.
I am getting this error.
java.lang.NumberFormatException: Infinite or NaN.
This is how I am converting it.
private BigDecimal convert(Double object) {
return new BigDecimal(object);
Does anybody know how to do this?
Thanks.

caesarkim1 wrote:
It seems to me that BigDecimal can't handle infinite number.Correct. As per the documentation in BigDecimal(double) and BigDecimal(String)
BigDecimal(double)
Throws: NumberFormatException - if val is infinite or NaN.
BigDecimal(String)Translates the string representation of a BigDecimal into a BigDecimal. The string representation consists of an optional sign, '+' ('\u002B') or '-' ('\u002D'), followed by a sequence of zero or more decimal digits ("the integer"), optionally followed by a fraction, optionally followed by an exponent
Throws: NumberFormatException - if val is not a valid representation of a BigDecimal

Similar Messages

  • The BMC reported failure in converting the document

    Hello,
    I have a problem with PDF generator. I launch a workflow with an attachment which contains a Word or a .ppt document. That document is sometimes well converted. But sometimes it is not well converted and a .log file is generated in the out directory. The .log file contains the following message:
    Failed to process job DDLaunchObject-2006-08-08 13-22-40.102.doc
    Error Code: 1,011
    Reason: The BMC reported failure in converting the document.
    Is anyone could help me?
    Thanks a lot.

    I had the same error so I checked my log file and noticed it was looking for Acrobat.exe which didn't exist.
    I guess what happened was I had Reader 8 installed before I installed PDFG. It didn't install Acrobat for some reason so I uninstalled Reader 8 and PFG and then reinstalled PDFG. Seems to be better now.

  • How can i convert a double to float

    double gallons;
    double startOdometer;
    double endOdometer;
    double mpg;
    double miles;
    endOdometer = Double.parseDouble (inputs);
    miles = endOdometer - startOdometer;                                                                 
    mpg = (miles/gallons) ;
    gallons = miles/mpg;
    mpg = Float.parseFloat(double);

    You would use a cast.
    double d = 1.4;
    float f = (float) d;But why do you want to convert a double into a float and then store it back into a double?????

  • Converting a Double To A String

    Is it possible to convert a double to a string. I need to retrieve a double value from an array and display it as a label in an applet.
    How do I convert the double value to a string so that I can use it in the applet as a label?
    Thanks

    try this.
    double mydbl = 0;
    String mystr = null;
    mysstr=mydbl+"".trim();
    Paulthis one is nice paul, but it is also possible to do it that way:
    double d = 0;
    String dStr = Double.toString(d);see also API for classes Boolean, Character, Integer, Byte, Float, Short
    all primitives can easyli be turned int for in which you can print them out.

  • Converting a double to binary

    Hey all,
    I am having difficultly trying to devise a simple method for converting a double to its binary representation. The value that I am dealing with is ~10^32, so I cannot use int or long. Any advice/suggestions would be appreciated. Shanks.

    prometheuzz wrote:
    Boojum317 wrote:
    Value = 711051181013210910132971103265
    Calculated binary = 100011000100001111100110000111110000000110000000100101001101011
    Value of calculated binary = 5.0535875047965512E18I am not checking your numbers, but I suspect you are confused how a floating point is represented in a binary notation. This is different than an integer value.
    Read the link that was posted earlier in your thread.Indeed.
    Long.toBinaryString(Double.doubleToLongBits(1.0))
    gives
    11111111110000000000000000000000000000000000000000000000000000which is correct.

  • How can I convert a double to string

    Hello,
    how can I convert a double value to a string value?
    Werner

    an other way: ;)
    double yourDouble;
    int intTmp;
    yourDouble = yourDouble * 100;
    yourDouble = yourDouble + 0.5;
    intTmp = yourDouble.intValue();
    yourDouble = intTmp;
    yourDouble = yourDouble / 100;you can write it some shorter...
    double yourDouble;
    int intTmp;
    yourDouble = yourDouble * 100 + 0.5;
    yourDouble = yourDouble.intValue() / 100;*100 moves the comma about two steps to the left.
    + 0.5 enables rounding!
    if your value is x.5 or larger you get x+1.?
    if its smaller than x.5 you get x.?
    by parsing the double value to an int the ? is cut.
    /100 moves the comma two steps back
    you get a double value with 2 decimals which is rounded.
    just my coins :)
    happy progging,
    Thof

  • How do i convert a double array (with spaces and tabs) to a string?

    Hi
    In our files, we have a mixture of spaces and tabs as a delimeter. How do I convert a double array into a string?
    Thank you.

    Not sure about the last part of your question.
    The Search and Replace pattern can be better than the simple Search and Replace string when you have to do complex searchs, such as detecting multiple spaces.
    Have a look at the attachment.
    CC
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    ReplaceSpaces.vi ‏27 KB

  • How to convert  Erik Anderson to BigDecimal?

    Hi,
    I have a Table field Value Author and the String is 'Erik Anderson'
    I want to convert this intoa BigDecimal. Here is the code::
    BigDecimal bg;
    Object valueObj = getObject(columnIndex);
    String value = valueObj == null ? "" : valueObj.toString();
    bg = new BigDecimal(Integer.parseInt(value));
    I am getting Error
    For input string: "Erik Anderson"
    Please Help!!

    Hi,
    Thank you all for the reply!
    I am using Crystal reports Xi and made a ResultSet Object and set this as ReportSource and when I want this to be viewd through Crystal, it is pulling the Data from the ResultSet and for the column Author, which I defined as a String, it gets the value 'Erik Anderson' correctly and calls for getBigDecimal.
    I have no clue why it should convert a String to BigDecimal to display it
    However
    bg = new BigDecimal("ADHHDJH HDAHKDH HDAHDHA");
    should work as per the API.
    I am not sure what the result should be. Can some one explain?

  • Double/float/BigDecimal

    Hi all
    What is the major difference between
    double, float, BigDecimal inorder to use for
    the accurate results in currency calculations.
    Thanks in advance.

    double and float are basically the same, other than double is twice as large. They are not accurate. I belive that (you can test this yourself) if you:
    <code>
    double d = .001 + .001 + .001 + .001;
    System.out.println(d == 0);
    </code>
    you get true. at least something similar to above shows this.
    BigDecimal is incredibly large and it is accurate.

  • How do I convert a double-byte encoded file to single-byte ASCII?

    Hello,
    I am working with XML files (apparently coded in UTF-8) which encoded in double-byte characters.
    The problem is the characters for end of line: 00 0D 00 0A
    This double byte end of line is causing a problem with a legacy conversion tool (which deals with 0D 0A). The file itself contains no
    accented/international characters, so in principle converting to single-byte should not cause any problems.
    I have tried to convert this file with tools like native2ascii and the conversion tools that are part of Notepad++ but without
    any luck - the "00 0D 00 0A" are still present in the output
    Can anyone point me to a tool or some code that can convet this file into single-byte?
    Thank you.

    Amiens wrote:
    native2ascii.exe -encoding UTF-16 -reverse INPUT.xml OUTPUT.xml
    gives 00 00 0 0D 00 00 00 0A
    so clearly that is not the required output.What you've got there is UTF-16 encoded text that's been converted to UTF-16. Get rid of the "-reverse" option and you should see the result you expect.

  • How do I convert a double to an int?

    I would like to use math.pow(), but math.pow() only take doubles as arguments and result and I need my result to be an int.
    Example:
    double a = 10;
    double b = 3;
    double c;
    c = math.pow(a,b);
    "Now, here I what to convert c to an int"

    Can't you say
    int d = Math.floor(c);
    ?

  • Converting a double to an int

    Can I convert a variable of type double to a variable of type int? The reason for this is I am creating a program that will draw graphs of parabolas, cubics, etc. and the user will be able to change the values for stretches, translations, etc.
    So my code for the drawing of a parabola at the moment is somewhat primitive, I just want the basic parabola drawn in. I've done a program that does exactly this using Turing (of all things...) but Java is proving to be more picky.
    int count = 0;
    int X = 0;
    double tempY = 0;
    int Y = 0;
    while(count <= 600){
         tempY = Math.pow(X - 300,2) + 200;
         Y = tempY;     //error here
         if(Y >= 0 && Y <= 400){
              g.fillOval(X, Y, 1, 1);
         count++;
         X++;
         }Don't worry about paintComponent() and all that, it's there I'm just posting the necessary parts you guys need to see.
    So the error I get is 'possible loss of precision' at the line indicated, and I know this, it's pretty obvious, but this is what I want/need to do as the fillOval will only accept ints for it's coordinates. I also tried forgetting about having the double value of tempY and doing the math to an int but then I get 'possible loss of precision' in the math line. If anyone can give me ideas/fixes to change a double into an int it would be much appreciated as this is what I really want to do, or if you can come up with alternative ways of doing what I need to do that would also be appreciated.
    EDIT
    In case you are wondering why I am adding and subtracting those values it's because my panel I'm drawing on is (600,400) and of course (0,0) is the top left corner rather than the center where it would be on a Cartesian plane, so I think I've made all the necassary adjustments so (0,0) is now in essentially the center of the panel. It's basically scanning across from the left to right and finding X^2 from '-300' to '300' but only drawing it in if the value for Y will appear in the panel. I know it's pretty fucked up and probably some really messy code, lol. I'm somewhat inexperienced and probably being a bit too adventurous.
    Edited by: vortex on Jan 15, 2008 11:07 AM
    Edited by: vortex on Jan 15, 2008 11:15 AM

    I haven't tried that, I will try that when I get to school. I think the issue could be that -300^2 may be too big to be an int? I was just thinking before I fell asleep about it last night and that could be it too...So naturally I'll just start from say, -100, or even -25 as that isn't exactly gonna fit on the graph so I'm just wasting processor power currently I suppose. Anyways I'm gonna try both of these out and get back to you guys.
    Another issue I'm foreseeing is that one of the graphs is the root of x, so I'm going to be dealing with decimals, that's fine for double but when I turn that into an int (assuming I ever figure out how to, hoping your idea, possibly coupled with mine works) how can I round/drop the decimals?
    Edited by: vortex on Jan 16, 2008 8:10 AM

  • Why do i always get conversion failure when converting pdf files to xls in exportpdf program?

    I have had export pdf for months.  I cannot export pdf files to excel files.  It always says conversion failure. Anyone have any idea why this is happening?  I am so frustrated!  This was supposed to make my payroll reports easier, but it has not helped at all.

    Hi denise/sharon,
    I can understand your frustration. Are you converting via the ExportPDF website, or from within Adobe Reader? Does the conversion failure occur every time that you try to convert a file (has it ever worked for you)?
    Since you're talking about payroll, I'm assuming that you're accessing ExportPDF from a corporate computer. You may want to check with your IT department to make sure there are no firewall/proxy settings that limit your access to the Internet.
    Also, make sure that you're using a supported web browser. You can find a list here: System Requirements | Adobe Acrobat Pro and Online Services
    Finally, if you're using Reader, you can try disabling OCR (optical character recognition) by following the steps in this document: How to disable Optical Character Recognition (OCR) when converting PDF to Word or Excel.
    Please let us know how it goes.
    Best,
    Sara

  • How to convert a double to integer ?

    Hi,
    how do convert an output of a pow(2,n) method of Math class to integer. Since this pow(x double, y bouble) gives an output of type double, how do i convert this output to integer if i want the value returned as an integer ?
    thanks
    aron

    By casting (but note that this may not yield the results you want)...
    class Test {
         public static void main(String[] argv) {
              double a = 5.5;
              double b = 6.6;
              int c = (int)(a + b);
              System.out.println(c);
    }

  • Converting a double to a float

    Hi,
    Sorry, this is one simplest of questions I guess but I have been searching and can't find the tutorial or process to convert number types.
    I have to update a float field in a database but the number I have in an array is a double
    This is my attempt
    prodrs.updateFloat("Price",Float.parse(myProduct.getPrice()));
    but I get a "cannot find symbol"
    Can someone please assist?

    double d = 1.2;
    float f = (float) d;Beware, if the value in your double is greater than the max value of float you will get unexpected results.

Maybe you are looking for

  • Jabber and iChat

    Hi All A question re iChat and Jabber accounts. I assume that when one has a conversation between two Jabber accounts using the iChat interface that it is using the Jabber protocol (XMPP) and not the AIM protocol. Is my understanding correct? If am I

  • How can I transfer contacts from a flash card to my iPhone 5s?

    How can I transfer contacts from a flash card to my iPhone 5s?

  • Dates for the receipts

    Hi Below is the demand situation day    req/ recipt qty 1          -10 2         -10 3          -10 7          30             production order 8          -10 After SNP Run day    req/ recipt qty 1          -10 2          -10 3          -10 3         

  • Data filter on gg ext

    Hi experts, We need to filter the data based on the below scenario , , please guide,how to use below filter on extract process the requirement is  , account table has 4 columns ,name , id, department , branch , we need to filter  only  DEPARTMENT in

  • IMovie will only import short videos from my camera.

    Hello, I recently bought a Sony CyberShot DSC-HX50 camera.   I filled one 8 GB memory card and have half-filled a 16 GB card (I was overseas and couldn't download photos to my MacBook Pro, which was at home).   I have the most recent version of iMovi