how do i get the number to display only 2 decimal places?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew Hausmann
    New Member
    • Oct 2010
    • 1

    #1

    how do i get the number to display only 2 decimal places?

    there is a valve that is being written to a tag and it displays a very long number. how do i get the number to display only 2 decimal places?
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    Use DecimalFormat to specify number of decimal places.

    Code:
    double d = 5.678965
    DecimalFormat dF = new DecimalFormat("0.00″);
    dFormat.format(d));
    Regards
    Dheeraj Joshi

    Comment

    Working...