Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Colleen Burton   on Jan 16 In Java Category.

  
Question Answered By: Andrew Brown   on Jan 16

In some of the other replies to your question people used
DecimalFormat. That is ok as long as the rounding method that you
want is ROUND_HALF_EVEN. Peronally I would use java.math.BigDecimal
to do number rounding. That way you can choose any rounding method
that you want. ie....

double d = 1.12345;
BigDecimal bd = new BigDecimal(d).setScale(3, BigDecimal.ROUND_HALF_UP);

If you want the string value:

String s = bd.toString();

If you want the double  value again:

d = bd.doubleValue();

As far as the SQL question is concerned I think if you just drop the
table and create again then the auto increment number will start at 1
again. You can also just "truncate" the table which in effect drops
and creates the table in 1 step.

Share: 

 

This Question has 11 more answer(s). View Complete Question Thread

 


Tagged: