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) {
78 # extern float fneg(float);
79 # extern double ftrunc(double);
81 # extern float wtos(unsigned int);
82 # extern double wtod(unsigned int);
83 # extern float ltos(long long unsigned int);
84 # extern double ltod(long long unsigned int);
86 # extern unsigned int stow(float);
87 # extern unsigned int dtow(double);
88 # extern unsigned long long stol(float);
89 # extern unsigned long long dtol(double);
91 # unsigned long long iin[] = { 0, 1, 16, 234987, 427386245, 0x7fff0000,
92 # 0xffff0000, 23602938196141, 72259248152500195, 9589010795705032704ull,
93 # 0xdcf5fbe299d0148aull, 0xffffffff00000000ull, -1 };
95 # double fin[] = { 0.17346516197824458, 442.0760005466251, 4342856.879893436,
96 # 4294967295.0, 98547543006.49626, 236003043787688.3, 9.499222733527032e+18,
97 # 1.1936266170755652e+19 };
102 # if (fneg(1.23f) != -1.23f) return 1;
103 # if (ftrunc(3.1415) != 3.0) return 2;
104 # if (ftrunc(-1.234) != -1.0) return 3;
106 # for (i=0; i<sizeof(iin)/sizeof(iin[0]); i++) {
107 # if (wtos(iin[i]) != (float) (unsigned int)iin[i])
109 # if (wtod(iin[i]) != (double)(unsigned int)iin[i])
111 # if (ltos(iin[i]) != (float) iin[i])
113 # if (ltod(iin[i]) != (double)iin[i])
116 # for (i=0; i<sizeof(fin)/sizeof(fin[0]); i++) {
117 # if (fin[i] >= 1LL << DBL_MANT_DIG)
119 # if (dtol(fin[i]) != (unsigned long long)fin[i])
121 # if((unsigned long long)fin[i] > UINT_MAX)
123 # if (dtow(fin[i]) != (unsigned int)fin[i])
125 # if (fin[i] >= 1LL << FLT_MANT_DIG)
127 # if (stol((float)fin[i]) != (unsigned long long)(float)fin[i])
129 # if (stow((float)fin[i]) != (unsigned int)(float)fin[i])