# floating point casts and conversions export function s $fneg(s %f) { @fneg %b0 =w cast %f %b1 =w xor 2147483648, %b0 %rs =s cast %b1 ret %rs } export function d $ftrunc(d %f) { @ftrunc %l0 =w dtosi %f %rt =d swtof %l0 ret %rt } export function s $wtos(w %w) { @start %rt =s uwtof %w ret %rt } export function d $wtod(w %w) { @start %rt =d uwtof %w ret %rt } export function s $ltos(l %l) { @start %rt =s ultof %l ret %rt } export function d $ltod(l %l) { @start %rt =d ultof %l ret %rt } # >>> driver # extern float fneg(float); # extern double ftrunc(double); # # extern float wtos(unsigned int); # extern double wtod(unsigned int); # extern float ltos(long long unsigned int); # extern double ltod(long long unsigned int); # # unsigned long long iin[] = { 0, 1, 16, 234987, 427386245, 0x7fff0000, # 0xffff0000, 23602938196141, 72259248152500195, 9589010795705032704ull, # 0xdcf5fbe299d0148aull, 0xffffffff00000000ull, -1 }; # # int main() { # int i; # # if (fneg(1.23f) != -1.23f) return 1; # if (ftrunc(3.1415) != 3.0) return 2; # if (ftrunc(-1.234) != -1.0) return 3; # # for (i=0; i