------------------------------------------------------------------ */ decCheckOperands -- check operand(s) to a routine */ res is the result structure (not checked; it will be set to */ quiet NaN if error found (and it is not NULL)) */ lhs is the first operand (may be DECUNRESU) */ rhs is the second (may be DECUNUSED)
| 7906 | /* The caller is expected to abandon immediately if 1 is returned. */ |
| 7907 | /* ------------------------------------------------------------------ */ |
| 7908 | static Flag decCheckOperands(decNumber *res, const decNumber *lhs, |
| 7909 | const decNumber *rhs, decContext *set) { |
| 7910 | Flag bad=0; |
| 7911 | if (set==NULL) { // oops; hopeless |
| 7912 | #if DECTRACE || DECVERB |
| 7913 | printf("Reference to context is NULL.\n"); |
| 7914 | #endif |
| 7915 | bad=1; |
| 7916 | return 1;} |
| 7917 | else if (set!=DECUNCONT |
| 7918 | && (set->digits<1 || set->round>=DEC_ROUND_MAX)) { |
| 7919 | bad=1; |
| 7920 | #if DECTRACE || DECVERB |
| 7921 | printf("Bad context [digits=%ld round=%ld].\n", |
| 7922 | (LI)set->digits, (LI)set->round); |
| 7923 | #endif |
| 7924 | } |
| 7925 | else { |
| 7926 | if (res==NULL) { |
| 7927 | bad=1; |
| 7928 | #if DECTRACE |
| 7929 | // this one not DECVERB as standard tests include NULL |
| 7930 | printf("Reference to result is NULL.\n"); |
| 7931 | #endif |
| 7932 | } |
| 7933 | if (!bad && lhs!=DECUNUSED) bad=(decCheckNumber(lhs)); |
| 7934 | if (!bad && rhs!=DECUNUSED) bad=(decCheckNumber(rhs)); |
| 7935 | } |
| 7936 | if (bad) { |
| 7937 | if (set!=DECUNCONT) decContextSetStatus(set, DEC_Invalid_operation); |
| 7938 | if (res!=DECUNRESU && res!=NULL) { |
| 7939 | decNumberZero(res); |
| 7940 | res->bits=DECNAN; // qNaN |
| 7941 | } |
| 7942 | } |
| 7943 | return bad; |
| 7944 | } // decCheckOperands |
| 7945 | |
| 7946 | /* ------------------------------------------------------------------ */ |
| 7947 | /* decCheckNumber -- check a number */ |
no test coverage detected