I went through the docs before posting here..Was not able to get clear answer. BigDecimal = new BigDecimal("1") creates new object with 1 as string...while BigDecimal = new BigDecimal(1) is as BigInteger...but in any case it should work. But this program is failing.
just as a tip for next time...just saying "my program doesn't work" is really pointless. There are thousands of ways it could "not work". One of three things should be happening:
1) You get a compiler error. If so, tell us the EXACT text of that error. There is a LOT of info there, once you learn how to read it
2) Your program crashes when it runs. Again, you'll get some kind of message telling you what went wrong.
3) Your program runs, but behaves differently than you expect. We don't know what you expect, nor do we know what it does do. You need to tell us both.
You will find you generally get much more help, better help, and quicker help, if you do the above.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
I went through the docs before posting here..Was not able to get clear answer. BigDecimal = new BigDecimal("1") creates new object with 1 as string...while BigDecimal = new BigDecimal(1) is as BigInteger
It says a lot more than that. You probably ought to read it, very closely. And a little bit of thinking and effort would have led you to try something like this:
...but in any case it should work. But this program is failing.
Saying it "should work" is meaningless. It's doing exactly what it should do. The problem is that you have erroneous assumptions about how a given bit of code "should" behave.
Hd Desai wrote:thanks again Ritchie...yes I read whole doc..and it was my mistake i was reading 1.5 javadoc...
BigDecimal constructor does not take int till 1.5 . . . .
What has an int got to do with it? You said earlier you were not using whole numbers throughout. So some of your code uses the BigDecimal(int) constructor and the rest the BigDecimal(double) constructor? As Jeff has said, we need to know the correct details before we can help.
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss