[Swift-devel] numeric type(s) in swift.

Ben Clifford benc at hawaga.org.uk
Wed Jul 25 05:30:22 CDT 2007


need to be careful a bit about casting between floating point and fixed 
precision types in the operator implementation.

ints are small enough that they fit within a double such that no precision 
is lost; but using eg. a java long would cause a problem (see below code)

public class casts {
    public static void main(String args[]) {

        long i = 9223372036854775784l;
        double d = (double) i;
        long i2 = (long)d;

        System.out.println("  i="+i);
        System.out.println("  d="+d);
        System.out.println(" i2="+i2);
        if(i != i2) System.out.println("Different");
    }
}



More information about the Swift-devel mailing list