Labels

algorithms (22) Design Patterns (20) java (19) linux (14) Snippet (13) service mix (6) soa (4)

Floating Point Magic

Try this and see the result

import java.io.*;
import java.util.*;
public class A {
public static void main(String args[]) {
double a1 = 0.10;
double a2 = 0.80;
double a3 = 4.00;

System.out.println("a1+a2+a3 :" + (a1 + a2 + a3));
System.out.println("a1+a3+a2 :" + (a1 + a3 + a2));
System.out.println("a2+a1+a3 :" + (a2 + a1 + a3));
System.out.println("a2+a3+a1 :" + (a2 + a3 + a1));
System.out.println("a3+a1+a2 :" + (a3 + a1 + a2));
System.out.println("a3+a2+a1 :" + (a3 + a2 + a1));

}
}



No comments:

Post a Comment

Search 24 Bytes