1 # floating point casts and conversions
4 function s $fneg(s %f) {
7 %b1 =w xor 2147483648, %b0
13 function d $ftrunc(d %f) {
21 function s $wtos(w %w) {
27 function d $wtod(w %w) {
34 function s $ltos(l %l) {
40 function d $ltod(l %l) {
47 function w $stow(s %f) {
53 function w $dtow(d %f) {
60 function l $stol(s %f) {
66 function l $dtol(d %f) {
77 # extern float fneg(float);
78 # extern double ftrunc(double);
80 # extern float wtos(unsigned int);
81 # extern double wtod(unsigned int);
82 # extern float ltos(long long unsigned int);
83 # extern double ltod(long long unsigned int);
85 # extern unsigned int stow(float);
86 # extern unsigned int dtow(double);
87 # extern unsigned long long stol(float);
88 # extern unsigned long long dtol(double);
90 # unsigned long long iin[] = { 0, 1, 16, 234987, 427386245, 0x7fff0000,
91 # 0xffff0000, 23602938196141, 72259248152500195, 9589010795705032704ull,
92 # 0xdcf5fbe299d0148aull, 0xffffffff00000000ull, -1 };
94 # double fin[] = { 0.17346516197824458, 442.0760005466251, 4342856.879893436,
95 # 4294967295.0, 98547543006.49626, 236003043787688.3, 9.499222733527032e+18,
96 # 1.1936266170755652e+19 };
101 # if (fneg(1.23f) != -1.23f) return 1;
102 # if (ftrunc(3.1415) != 3.0) return 2;
103 # if (ftrunc(-1.234) != -1.0) return 3;
105 # for (i=0; i<sizeof(iin)/sizeof(iin[0]); i++) {
106 # if (wtos(iin[i]) != (float) (unsigned int)iin[i])
108 # if (wtod(iin[i]) != (double)(unsigned int)iin[i])
110 # if (ltos(iin[i]) != (float) iin[i])
112 # if (ltod(iin[i]) != (double)iin[i])
115 # for (i=0; i<sizeof(fin)/sizeof(fin[0]); i++) {
116 # if (stol((float)fin[i]) != (unsigned long long)(float)fin[i])
118 # if (dtol(fin[i]) != (unsigned long long)fin[i])
120 # if((unsigned long long)fin[i] > UINT_MAX)
122 # if (stow((float)fin[i]) != (unsigned int)(float)fin[i])
124 # if (dtow(fin[i]) != (unsigned int)fin[i])