For rounding, use the Math.round() method. It only rounds to a whole number, so multiply by 100d and round and divide by 100d. To print out 12.3400 use the methods which use % tags, eg printf or format. Details in the Formatter class.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 44016

33

posted

0

By the way, you are not using the same rounding convention as in Math.round(). For round-toward-zero, multiply by 100, cast to an int or long and divide by 100d.

I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com