Results 1 to 5 of 5
  1. #1
    valery is offline Member
    Join Date
    Jul 2007
    Posts
    32
    Rep Power
    0

    Default How to convert a string into a BigInteger

    How do I convert a string into a BigInteger?
    For example a string saying "Hello World "to big integer
    can I do that?
    how?
    thanks

  2. #2
    gabriel is offline Member
    Join Date
    Jul 2007
    Posts
    41
    Rep Power
    0

    Default

    very easy vale:
    Java Code:
    import java.math.*;
    ...
    ...
    BigInteger bi = new BigInteger(myString);

  3. #3
    muneeb is offline Member
    Join Date
    Sep 2011
    Posts
    3
    Rep Power
    0

    Default Re: How to convert a string into a BigInteger

    /*import java.math.*;
    ...
    ...
    BigInteger bi = new BigInteger(myString);*/


    i have tried above piece of code it throw exception..

    "Exception in thread "main" java.lang.NumberFormatException: For input string: "hello" "

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,001
    Blog Entries
    7
    Rep Power
    20

    Default Re: How to convert a string into a BigInteger

    Quote Originally Posted by muneeb View Post
    /*import java.math.*;
    ...
    ...
    BigInteger bi = new BigInteger(myString);*/


    i have tried above piece of code it throw exception..

    "Exception in thread "main" java.lang.NumberFormatException: For input string: "hello" "
    Does the String "hello" represent a number to you?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

Similar Threads

  1. how to convert String number to int
    By gabriel in forum New To Java
    Replies: 5
    Last Post: 08-02-2009, 03:46 PM
  2. convert string to a double?
    By javaMike in forum Advanced Java
    Replies: 2
    Last Post: 11-27-2007, 03:10 AM
  3. convert string to float
    By miss_dot in forum NetBeans
    Replies: 1
    Last Post: 11-14-2007, 11:26 PM
  4. Can't convert java.lang.String to int.
    By Albert in forum AWT / Swing
    Replies: 2
    Last Post: 07-13-2007, 05:05 PM
  5. Error: convert from String to long
    By bbq in forum New To Java
    Replies: 1
    Last Post: 06-29-2007, 07:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •