× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



This worked for me.  Is a little bit of a run around.

import java.io.*;
import java.util.*;
import java.lang.*;
import java.text.*;
import java.math.*;

public class Test {


//--------------------------------------------------
    public static void main(String args[]){
        new Test();
        System.exit(0);
    }

//--------------------------------------------------
    public Test() {
       double a = 1.244;
       double b = 1.245;
       double c = 1.246;

       try {
         BigDecimal bd = new BigDecimal(a);
         BigDecimal bd1 = bd.setScale(2, BigDecimal.ROUND_HALF_UP);
         dsp("was: " + a + " ,now: " + bd1.toString());
         bd = new BigDecimal(b);
         bd1 = bd.setScale(2, BigDecimal.ROUND_HALF_UP);
         dsp("was: " + b + " ,now: " + bd1.toString());
         bd = new BigDecimal(c);
         bd1 = bd.setScale(2, BigDecimal.ROUND_HALF_UP);
         dsp("was: " + c + " ,now: " + bd1.toString());
         }
       catch(Exception e) { e.printStackTrace(); }
    }



//--------------------------------------------------
  private void dsp(String s) { System.out.println(s); }

}




As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.