Results 21 to 34 of 34
- 09-26-2010, 12:33 AM #21
Member
- Join Date
- Sep 2010
- Posts
- 42
- Rep Power
- 0
-
-
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.
- 09-26-2010, 12:36 AM #24
Member
- Join Date
- Sep 2010
- Posts
- 42
- Rep Power
- 0
i dont know what to do!!!! i looked at the sight you suggested all day but i dont understand what the method is!!
- 09-26-2010, 12:38 AM #25
Member
- Join Date
- Sep 2010
- Posts
- 42
- Rep Power
- 0
what does this mean? how do i use this to change a double to a BigDecimal?public BigDecimal(double val)
- 09-26-2010, 12:41 AM #26
Member
- Join Date
- Sep 2010
- Posts
- 42
- Rep Power
- 0
what does this mean? how do i use this to change a double to a BigDecimal?public BigDecimal(double val)
-
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:
To use it, you simply get your String from the Scanner object and create your BigDecimal:Java Code:public BigDecimal(String val)
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.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
Luck!
-
- 09-26-2010, 12:46 AM #29
Member
- Join Date
- Sep 2010
- Posts
- 42
- Rep Power
- 0
so, trying to understand your post, when you put
you're making the input, that would usaully be a string, into a BigDecimal?BigDecimal myBigDecimal = new BigDecimal(myScanner.nextLine());
- 09-26-2010, 12:48 AM #30
Member
- Join Date
- Sep 2010
- Posts
- 42
- Rep Power
- 0
cool thanks but let me try it...
-
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);
- 09-26-2010, 12:52 AM #32
Member
- Join Date
- Sep 2010
- Posts
- 42
- Rep Power
- 0
so i should rewrite my program with BigDecimals instead of the previous?
- 09-26-2010, 12:58 AM #33
Member
- Join Date
- Sep 2010
- Posts
- 42
- Rep Power
- 0
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!
Similar Threads
-
matrix multiply
By slixtrix in forum New To JavaReplies: 8Last Post: 09-13-2010, 06:50 AM -
multiply two matrixes
By smart princess in forum New To JavaReplies: 8Last Post: 12-06-2009, 06:43 PM -
BigDecimal question
By orchid in forum New To JavaReplies: 2Last Post: 08-12-2008, 01:44 PM -
convert a really big string (len 39) to bigdecimal
By coolsig in forum Advanced JavaReplies: 6Last Post: 06-14-2008, 02:48 AM -
BigDecimal - Help formulating if statments
By shinjitsunohana in forum New To JavaReplies: 5Last Post: 04-28-2008, 10:12 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks