Code to add two float values in Java and Android

Example 1:

float f1=(float) 101.9;
BigDecimal flotAddSubtract = new BigDecimal("0.2");
System.out.println("=====float values==="+new BigDecimal(f1+"").add(flotAddSubtract));

Example 2:
float f1=(float) 101.7;
BigDecimal step = new BigDecimal("0.2");
BigDecimal step1 = new BigDecimal(f1+"");
System.out.println("=====float values==="+step1);

Example 3:
BigDecimal step = new BigDecimal("0.1");
for (BigDecimal value = BigDecimal.ZERO;
     value.compareTo(BigDecimal.ONE) < 0;
     value = value.add(step)) {


Popular posts from this blog

Custom Dialog with no title and full screen in Android

Best working code to set Date limits on Date Picker Dialog,in Android

code to display .pdf,.text,.DOC,.DOCX,.doc extension files exists in SDCard