Page 2 of 2 FirstFirst 12
Results 21 to 34 of 34
  1. #21
    s0meb0dy is offline Member
    Join Date
    Sep 2010
    Posts
    42
    Rep Power
    0

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

    Default

    Quote Originally Posted by s0meb0dy View Post
    this has nothing to do with beer
    Exactly. And this:
    i can only use double with the Math.pow(); method
    has nothing to do with your problem. BigDecimal has its own power method.

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

    Default

    Quote Originally Posted by s0meb0dy View Post
    yeah i checked but i didnt understand the methods
    What don't you understand about them? First of all, do you understand the BigDecimal constructors whereby you can get a String (that holds numeric info) and construct a BigDecimal with it? Please read that section of the API again. If you still don't understand it, then please come on back with a specific question.

  4. #24
    s0meb0dy is offline Member
    Join Date
    Sep 2010
    Posts
    42
    Rep Power
    0

    Default

    i dont know what to do!!!! i looked at the sight you suggested all day but i dont understand what the method is!!

  5. #25
    s0meb0dy is offline Member
    Join Date
    Sep 2010
    Posts
    42
    Rep Power
    0

    Default

    public BigDecimal(double val)
    what does this mean? how do i use this to change a double to a BigDecimal?

  6. #26
    s0meb0dy is offline Member
    Join Date
    Sep 2010
    Posts
    42
    Rep Power
    0

    Default

    public BigDecimal(double val)
    what does this mean? how do i use this to change a double to a BigDecimal?

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

    Default

    Quote Originally Posted by s0meb0dy View Post
    i dont know what to do!!!! i looked at the sight you suggested all day but i dont understand what the method is!!
    Slow down.

    First off, have you used the API, do you understand how to use it? If not, you need to get familiar with it as your Java experience will be very frustrating without this skill.

    Go to the BigDecimal API here: BigDecimal (Java Platform SE 6)

    And find the section called "Constructor Summary". It will show all the constructors available for use when you want to create a BigDecimal object. There's really nothing confusing about them. For instance, there's one that describes how to use a String to create a BigDecimal object, and it's nothing more than this:

    Java Code:
    public BigDecimal(String val)
    To use it, you simply get your String from the Scanner object and create your BigDecimal:

    Java Code:
          Scanner myScanner = new Scanner(System.in);
    
          System.out.print("Enter a Number: ");
          BigDecimal myBigDecimal = new BigDecimal(myScanner.nextLine()); // error if they don't enter numeric data
    Next look at the methods section and you'll find one on how to get power called "pow". Please look it over and try to figure out how to use it in a very simple program. If the program doesn't work, please post it here and again, we'll help you.

    Luck!

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

    Default

    Quote Originally Posted by s0meb0dy View Post
    what does this mean? how do i use this to change a double to a BigDecimal?
    It means that you can convert a double to a BigDecimal simply by passing it into the parameter of a BigDecimal constructor:

    Java Code:
    double myDouble = 3.0;
    BigDecimal myBigDecimal = new BigDecimal(myDouble);
    See, nothing to it! :)

  9. #29
    s0meb0dy is offline Member
    Join Date
    Sep 2010
    Posts
    42
    Rep Power
    0

    Default

    so, trying to understand your post, when you put
    BigDecimal myBigDecimal = new BigDecimal(myScanner.nextLine());
    you're making the input, that would usaully be a string, into a BigDecimal?

  10. #30
    s0meb0dy is offline Member
    Join Date
    Sep 2010
    Posts
    42
    Rep Power
    0

    Default

    cool thanks but let me try it...

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

    Default

    Quote Originally Posted by s0meb0dy View Post
    so, trying to understand your post, when you put
    you're making the input, that would usaully be a string, into a BigDecimal?
    It is a String but is passed into the BigDecimal constructor to be made into a BigDecimal. I could just as easily have done:

    Java Code:
          Scanner myScanner = new Scanner(System.in);
    
          System.out.print("Enter a Number: ");
          String reply = myScanner.nextLine();
          BigDecimal myBigDecimal = new BigDecimal(reply);

  12. #32
    s0meb0dy is offline Member
    Join Date
    Sep 2010
    Posts
    42
    Rep Power
    0

    Default

    so i should rewrite my program with BigDecimals instead of the previous?

  13. #33
    s0meb0dy is offline Member
    Join Date
    Sep 2010
    Posts
    42
    Rep Power
    0

    Default

    how do i mark the post as solved. Thanks very much i think i understand the website you gave me more now. thanks

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

    Default

    Quote Originally Posted by s0meb0dy View Post
    how do i mark the post as solved. Thanks very much i think i understand the website you gave me more now. thanks
    Great because knowledge of how to use the API will give you more help in the future than I or even Norm can. It is probably the single most important skill you'll need to get you from a beginner Java programmer to an intermediate.

    And to mark the post as solved, please look at the Thread Tools at the top.

    Much luck!

Page 2 of 2 FirstFirst 12

Similar Threads

  1. matrix multiply
    By slixtrix in forum New To Java
    Replies: 8
    Last Post: 09-13-2010, 06:50 AM
  2. multiply two matrixes
    By smart princess in forum New To Java
    Replies: 8
    Last Post: 12-06-2009, 06:43 PM
  3. BigDecimal question
    By orchid in forum New To Java
    Replies: 2
    Last Post: 08-12-2008, 01:44 PM
  4. convert a really big string (len 39) to bigdecimal
    By coolsig in forum Advanced Java
    Replies: 6
    Last Post: 06-14-2008, 02:48 AM
  5. BigDecimal - Help formulating if statments
    By shinjitsunohana in forum New To Java
    Replies: 5
    Last Post: 04-28-2008, 10:12 AM

Posting Permissions

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