Changeset a35b458 in mainline for uspace/app/tester/float/softfloat1.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tester/float/softfloat1.c
r3061bc1 ra35b458 100 100 if (a < b) 101 101 return -1; 102 102 103 103 if (a > b) 104 104 return 1; 105 105 106 106 return 0; 107 107 } … … 111 111 if (a < b) 112 112 return -1; 113 113 114 114 if (a > b) 115 115 return 1; 116 116 117 117 return 0; 118 118 } … … 122 122 { 123 123 uint_to_double_op_t op = (uint_to_double_op_t) f; 124 124 125 125 double c; 126 126 double sc; 127 127 op(uop_a[i], &c, &sc); 128 128 129 129 *pic = (cmptype_t) (c * PRECISION); 130 130 *pisc = (cmptype_t) (sc * PRECISION); … … 135 135 { 136 136 double_to_uint_op_t op = (double_to_uint_op_t) f; 137 137 138 138 unsigned int c; 139 139 unsigned int sc; 140 140 op(dop_a[i], &c, &sc); 141 141 142 142 *pic = (cmptype_t) c; 143 143 *pisc = (cmptype_t) sc; … … 148 148 { 149 149 float_binary_op_t op = (float_binary_op_t) f; 150 150 151 151 float c; 152 152 float sc; 153 153 op(fop_a[i], fop_a[j], &c, &sc); 154 154 155 155 *pic = (cmptype_t) (c * PRECISION); 156 156 *pisc = (cmptype_t) (sc * PRECISION); … … 161 161 { 162 162 float_cmp_op_t op = (float_cmp_op_t) f; 163 163 164 164 op(dop_a[i], dop_a[j], pis, piss); 165 165 } … … 169 169 { 170 170 double_binary_op_t op = (double_binary_op_t) f; 171 171 172 172 double c; 173 173 double sc; 174 174 op(dop_a[i], dop_a[j], &c, &sc); 175 175 176 176 *pic = (cmptype_t) (c * PRECISION); 177 177 *pisc = (cmptype_t) (sc * PRECISION); … … 182 182 { 183 183 double_cmp_op_t op = (double_cmp_op_t) f; 184 184 185 185 op(dop_a[i], dop_a[j], pis, piss); 186 186 } … … 189 189 { 190 190 bool correct = true; 191 191 192 192 for (unsigned int i = 0; i < OPERANDS; i++) { 193 193 cmptype_t ic; 194 194 cmptype_t isc; 195 195 196 196 template(f, i, &ic, &isc); 197 197 cmptype_t diff = ic - isc; 198 198 199 199 if (diff != 0) { 200 200 TPRINTF("i=%u ic=%" PRIdCMPTYPE " isc=%" PRIdCMPTYPE "\n", … … 203 203 } 204 204 } 205 205 206 206 return correct; 207 207 } … … 210 210 { 211 211 bool correct = true; 212 212 213 213 for (unsigned int i = 0; i < OPERANDS; i++) { 214 214 for (unsigned int j = 0; j < OPERANDS; j++) { 215 215 cmptype_t ic; 216 216 cmptype_t isc; 217 217 218 218 template(f, i, j, &ic, &isc); 219 219 cmptype_t diff = ic - isc; 220 220 221 221 if (diff != 0) { 222 222 TPRINTF("i=%u, j=%u ic=%" PRIdCMPTYPE … … 226 226 } 227 227 } 228 228 229 229 return correct; 230 230 } … … 275 275 return; 276 276 } 277 277 278 278 *pc = a / b; 279 279 *psc = div_float(a, b); … … 284 284 { 285 285 *pis = fcmp(a, b); 286 286 287 287 if (is_float_lt(a, b) == -1) 288 288 *piss = -1; … … 320 320 return; 321 321 } 322 322 323 323 *pc = a / b; 324 324 *psc = div_double(a, b); … … 329 329 { 330 330 *pis = dcmp(a, b); 331 331 332 332 if (is_double_lt(a, b) == -1) 333 333 *piss = -1; … … 343 343 { 344 344 bool err = false; 345 345 346 346 if (!test_template_binary(float_template_binary, float_add_operator)) { 347 347 err = true; 348 348 TPRINTF("%s\n", "Float addition failed"); 349 349 } 350 350 351 351 if (!test_template_binary(float_template_binary, float_sub_operator)) { 352 352 err = true; 353 353 TPRINTF("%s\n", "Float addition failed"); 354 354 } 355 355 356 356 if (!test_template_binary(float_template_binary, float_mul_operator)) { 357 357 err = true; 358 358 TPRINTF("%s\n", "Float multiplication failed"); 359 359 } 360 360 361 361 if (!test_template_binary(float_template_binary, float_div_operator)) { 362 362 err = true; 363 363 TPRINTF("%s\n", "Float division failed"); 364 364 } 365 365 366 366 if (!test_template_binary(float_compare_template, float_cmp_operator)) { 367 367 err = true; 368 368 TPRINTF("%s\n", "Float comparison failed"); 369 369 } 370 370 371 371 if (!test_template_binary(double_template_binary, double_add_operator)) { 372 372 err = true; 373 373 TPRINTF("%s\n", "Double addition failed"); 374 374 } 375 375 376 376 if (!test_template_binary(double_template_binary, double_sub_operator)) { 377 377 err = true; 378 378 TPRINTF("%s\n", "Double addition failed"); 379 379 } 380 380 381 381 if (!test_template_binary(double_template_binary, double_mul_operator)) { 382 382 err = true; 383 383 TPRINTF("%s\n", "Double multiplication failed"); 384 384 } 385 385 386 386 if (!test_template_binary(double_template_binary, double_div_operator)) { 387 387 err = true; 388 388 TPRINTF("%s\n", "Double division failed"); 389 389 } 390 390 391 391 if (!test_template_binary(double_compare_template, double_cmp_operator)) { 392 392 err = true; 393 393 TPRINTF("%s\n", "Double comparison failed"); 394 394 } 395 395 396 396 if (!test_template_unary(uint_to_double_template, 397 397 uint_to_double_operator)) { … … 399 399 TPRINTF("%s\n", "Conversion from unsigned int to double failed"); 400 400 } 401 401 402 402 if (!test_template_unary(double_to_uint_template, 403 403 double_to_uint_operator)) { … … 405 405 TPRINTF("%s\n", "Conversion from double to unsigned int failed"); 406 406 } 407 407 408 408 if (!test_template_unary(double_to_uint_template, 409 409 double_to_int_operator)) { … … 411 411 TPRINTF("%s\n", "Conversion from double to signed int failed"); 412 412 } 413 413 414 414 if (err) 415 415 return "Software floating point imprecision"; 416 416 417 417 return NULL; 418 418 }
Note:
See TracChangeset
for help on using the changeset viewer.