------------------------------------------------------------------ */ to-number -- conversion from numeric string */ / decimal128FromString(result, string, set); */ / result is the decimal128 format number which gets the result of */ the conversion */ string is the character string which should contain a vali
| 449 | /* If an error occurs, the result will be a valid decimal128 NaN. */ |
| 450 | /* ------------------------------------------------------------------ */ |
| 451 | decimal128 * decimal128FromString(decimal128 *result, const char *string, |
| 452 | decContext *set) { |
| 453 | decContext dc; // work |
| 454 | decNumber dn; // .. |
| 455 | |
| 456 | decContextDefault(&dc, DEC_INIT_DECIMAL128); // no traps, please |
| 457 | dc.round=set->round; // use supplied rounding |
| 458 | |
| 459 | decNumberFromString(&dn, string, &dc); // will round if needed |
| 460 | decimal128FromNumber(result, &dn, &dc); |
| 461 | if (dc.status!=0) { // something happened |
| 462 | decContextSetStatus(set, dc.status); // .. pass it on |
| 463 | } |
| 464 | return result; |
| 465 | } // decimal128FromString |
| 466 | |
| 467 | /* ------------------------------------------------------------------ */ |
| 468 | /* decimal128IsCanonical -- test whether encoding is canonical */ |
nothing calls this directly
no test coverage detected