Lines Matching full:exponent
60 /* precision (up to 999,999,999 digits) and arbitrary exponent */
69 /* be finite, positive, have an exponent of zero, and all digits */
71 /* which are 0 or 1 (and will have exponent=0 and a sign of 0). */
136 /* 4. Exponent checking is minimized by allowing the exponent to */
141 /* overflow (the most negative valid exponent is -1999999997, for */
142 /* a 999999999-digit number with adjusted exponent of -999999999). */
396 /* Invalid is set if the decNumber does not have exponent==0 or if */
404 /* special or too many digits, or bad exponent */
405 if (dn->bits&DECSPECIAL || dn->digits>10 || dn->exponent!=0) ; /* bad */
439 /* special or too many digits, or bad exponent, or negative (<0) */
440 if (dn->bits&DECSPECIAL || dn->digits>10 || dn->exponent!=0
497 /* exponent (set.emax and set.emin), determining if */
502 /* The length of the coefficient and the size of the exponent are */
510 Int exponent=0; /* working exponent [assume 0] */
611 /* had some digits; exponent is only valid sequence now */
612 Flag nege; /* 1=negative exponent */
613 const char *firstexp; /* -> first significant exponent digit */
616 /* Found 'e' or 'E' -- now process explicit exponent */
625 firstexp=c; /* save exponent digit place */
628 exponent=X10(exponent)+(Int)*c-(Int)'0';
634 /* if it was too long the exponent may have wrapped, so check */
637 if (c>firstexp+9+1 || *firstexp>'1') exponent=DECNUMMAXE*2;
640 if (nege) exponent=-exponent; /* was negative */
665 exponent-=(last-dotchar); /* adjust exponent */
712 dn->exponent=exponent;
724 if ((dn->exponent-1<set->emin-dn->digits)
725 || (dn->exponent-1>set->emax-set->digits)) {
767 dzero.exponent=rhs->exponent; /* [no coefficient expansion] */
825 if (lhs->exponent!=0 || decNumberIsSpecial(lhs) || decNumberIsNegative(lhs)
826 || rhs->exponent!=0 || decNumberIsSpecial(rhs) || decNumberIsNegative(rhs)) {
866 res->exponent=0; /* integer */
1222 if (rhs->exponent!=0 || decNumberIsSpecial(rhs) || decNumberIsNegative(rhs)) {
1253 res->exponent=0; /* integer */
1329 /* decNumberLogB - get adjusted exponent, by 754 rules */
1338 /* an exponent of +999999999, or one digit and an exponent of */
1341 /* This returns the adjusted exponent of A after (in theory) padding */
1343 /* same value. The exponent is not limited by emin/emax. */
1369 Int ae=rhs->exponent+rhs->digits-1; /* adjusted exponent */
1403 /* requested digits and t is the number of digits in the exponent */
1417 Int t; /* digits in exponent of A */
1469 /* the exponent, conveniently, is the power of 10; making */
1473 uprv_decNumberFromInt32(w, w->exponent);
1482 /* number of digits in a, including exponent' as compared to the */
1667 dzero.exponent=rhs->exponent; /* [no coefficient expansion] */
1704 dtiny.exponent=DEC_MIN_EMIN-1; /* .. smaller than tiniest */
1741 dtiny.exponent=DEC_MIN_EMIN-1; /* .. smaller than tiniest */
1804 dtiny.exponent=DEC_MIN_EMIN-1; /* .. smaller than tiniest */
1841 if (lhs->exponent!=0 || decNumberIsSpecial(lhs) || decNumberIsNegative(lhs)
1842 || rhs->exponent!=0 || decNumberIsSpecial(rhs) || decNumberIsNegative(rhs)) {
1880 res->exponent=0; /* integer */
1910 dzero.exponent=rhs->exponent; /* [no coefficient expansion] */
2042 res->exponent=-shift; /* make 1.0000... */
2127 /* is the total digits, including exponent), or the requested */
2128 /* precision, if larger, + 4; 6 is used for the exponent */
2149 aset.digits=reqdigits+(rhs->digits+rhs->exponent)+2;
2182 dac->exponent=-shift; /* make 1.0000... */
2296 /* decNumberQuantize -- force exponent to requested value */
2299 /* of C (by rounding or shifting) such that the exponent (-scale) */
2300 /* of C has exponent of B. The numerical value of C will equal A, */
2305 /* rhs is B, the number with exponent to match */
2310 /* Unless there is an error or the result is infinite, the exponent */
2385 /* decNumberRescale -- force exponent to requested value */
2388 /* of C (by rounding or shifting) such that the exponent (-scale) */
2394 /* rhs is B, the requested exponent */
2399 /* Unless there is an error or the result is infinite, the exponent */
2469 /* the exponent or the sign of A. If lhs->digits is less than */
2494 else if (decNumberIsInfinite(rhs) || rhs->exponent!=0)
2615 else if (lhs->exponent==rhs->exponent) ret=1;
2639 Int reqexp; /* requested exponent change [B] */
2651 else if (decNumberIsInfinite(rhs) || rhs->exponent!=0)
2663 res->exponent+=reqexp; /* adjust the exponent */
2685 /* the exponent or the sign of A. */
2707 else if (decNumberIsInfinite(rhs) || rhs->exponent!=0)
2785 /* var e := getexp(x) % exponent part of x */
2792 /* approx := .0819 + 2.59 * f % exponent */
2820 /* result setexp(approx, e div 2) % fix exponent */
2836 Int exp; /* working exponent */
2837 Int ideal; /* ideal (preferred) exponent */
2889 /* calculate the ideal (preferred) exponent [floor(exp/2)] */
2890 /* [It would be nicer to write: ideal=rhs->exponent>>1, but this */
2892 ideal=(rhs->exponent&~1)/2; /* target */
2897 res->exponent=ideal; /* use the ideal [safe] */
2898 /* use decFinish to clamp any out-of-range exponent, etc. */
2940 /* copy rhs -> f, save exponent, and reduce so 0.1 <= f < 1 */
2942 exp=f->exponent+f->digits; /* adjusted to Hull rules */
2943 f->exponent=-(f->digits); /* to range */
2953 /* Calculate initial approximation, and allow for odd exponent */
2957 if ((exp & 1)==0) { /* even exponent */
2959 t->exponent=-3;
2960 a->exponent=-3;
2972 else { /* odd exponent */
2974 f->exponent--; /* f=f/10 */
2976 t->exponent=-4;
2977 a->exponent=-2;
2999 t->exponent=-1; /* .. */
3013 /* having the correct exponent so as to handle subnormals */
3017 a->exponent+=exp/2; /* set correct exponent */
3023 /* Overflow was possible if the input exponent was out-of-range, */
3035 a->exponent-=exp/2; /* back to 0.1->1 */
3043 t->exponent=-a->digits-1; /* make 0.5 ulp */
3050 t->exponent++; /* make 1.0 ulp */
3064 t->exponent++; /* make 1.0 ulp */
3077 a->exponent+=exp/2; /* set correct exponent */
3102 /* use closest exponent to ideal... */
3103 Int todrop=ideal-a->exponent; /* most that can be dropped */
3108 Int maxdrop=maxexp-a->exponent;
3119 a->exponent+=todrop; /* maintain numerical value */
3130 Int ae=rhs->exponent+rhs->digits-1; /* adjusted exponent */
3196 /* rescale(rhs, 0) if rhs->exponent is <0. */
3222 if (rhs->exponent>=0) return uprv_decNumberCopy(res, rhs);
3223 /* that was easy, but if negative exponent there is work to do... */
3227 uprv_decNumberZero(&dn); /* make a number with exponent 0 */
3271 if (lhs->exponent!=0 || decNumberIsSpecial(lhs) || decNumberIsNegative(lhs)
3272 || rhs->exponent!=0 || decNumberIsSpecial(rhs) || decNumberIsNegative(rhs)) {
3310 res->exponent=0; /* integer */
3392 dest->exponent=src->exponent;
3544 Int ae; /* adjusted exponent */
3552 ae=dn->exponent+dn->digits-1; /* adjusted exponent */
3564 Int ae; /* adjusted exponent */
3572 ae=dn->exponent+dn->digits-1; /* adjusted exponent */
3622 dn->exponent=0;
3649 Int exp=dn->exponent; /* local copy */
3698 /* non-0 exponent -- assume plain form */
3716 /* if dealing with zero still produce an exponent which is a */
3727 } /* need exponent */
3783 /* lay out the exponent [_itoa or equivalent is not ANSI C] */
3900 Int lexp=lhs->exponent; /* save in case LHS==RES */
3908 /* exponent will be the lower of the two */
3909 adjust=lexp-res->exponent; /* adjustment needed [if -ve] */
3911 if (adjust<0) res->exponent=lexp; /* set exponent */
3925 res->exponent+=adjust; /* set the exponent. */
3936 Int rexp=rhs->exponent; /* save in case RHS==RES */
3943 /* exponent will be the lower of the two */
3945 adjust=rexp-res->exponent; /* adjustment needed [if -ve] */
3952 res->exponent+=adjust; /* set the exponent. */
3964 padding=rhs->exponent-lhs->exponent;
3971 && rhs->exponent>=set->emin /* [some normals drop through] */
3972 && rhs->exponent<=set->emax-set->digits+1 /* [could clamp] */
4039 res->exponent-=shift; /* adjust the exponent. */
4080 res->exponent=lhs->exponent; /* .. operands (even if aliased) */
4234 /* exp=exp+1 -- set the proper exponent */
4279 Int exponent; /* working exponent */
4280 Int maxexponent=0; /* DIVIDE maximum exponent if unrounded */
4341 /* for DIVIDEINT the exponent is always 0. For DIVIDE, result */
4342 /* is a 0 with infinitely negative exponent, clamped to minimum */
4344 res->exponent=set->emin-set->digits+1;
4377 exponent=lhs->exponent-rhs->exponent; /* ideal exponent */
4380 res->exponent=exponent; /* exponent, too */
4381 decFinalize(res, set, &residue, status); /* check exponent */
4388 exponent=rhs->exponent; /* [save in case overwrite] */
4390 if (exponent<res->exponent) res->exponent=exponent; /* use lower */
4397 /* Precalculate exponent. This starts off adjusted (and hence fits */
4398 /* in 31 bits) and becomes the usual unadjusted exponent as the */
4401 exponent=(lhs->exponent+lhs->digits)-(rhs->exponent+rhs->digits);
4403 /* If the working exponent is -ve, then some quick exits are */
4406 if (exponent<0 && !(op==DIVIDE)) {
4415 /* (or equal) exponent */
4416 if (lhs->exponent<=rhs->exponent) {
4417 if (op&REMAINDER || exponent<-1) {
4496 /* but the exponent was calculated on the assumption that they are */
4497 /* both left-aligned. Adjust the exponent to compensate: add the */
4501 for (pow=&powers[1]; *msu1>=*pow; pow++) exponent--;
4502 for (pow=&powers[1]; *msu2>=*pow; pow++) exponent++;
4508 /* doing a remainder.) Also ensure the exponent is not negative. */
4514 if (exponent<0) cut=-exponent;
4515 else cut=DECDPUN-exponent%DECDPUN;
4517 exponent+=cut; /* maintain numerical value */
4523 maxexponent=lhs->exponent-rhs->exponent; /* save */
4528 exponent-=DECDPUN; /* update the exponent */
4618 if ((op&DIVIDE) && (exponent<=maxexponent)) break;
4623 if (exponent==0 && !(op&DIVIDE)) break;
4628 exponent-=DECDPUN; /* update the exponent */
4652 /* exponent is 'loose'. */
4659 if (exponent>=maxexponent) break; /* don't chop real 0s */
4666 exponent++;
4672 /* [exponent was adjusted in the loop] */
4680 if (accdigits+exponent>reqdigits) {
4685 /* [Here, the exponent will be 0, because var1 was adjusted */
4697 Int exp=lhs->exponent; /* save min(exponents) */
4698 if (rhs->exponent<exp) exp=rhs->exponent;
4703 res->exponent=exp; /* .. with proper exponent */
4717 postshift=var1initpad+exponent-lhs->exponent+rhs->exponent;
4718 /* [the 'exponent' term accounts for the shifts during divide] */
4727 exponent=lhs->exponent; /* exponent is smaller of lhs & rhs */
4728 if (rhs->exponent<exponent) exponent=rhs->exponent;
4745 /* RHS. The remainder's exponent may be smaller than the RHS's. */
4747 rhs->exponent-exponent);
4788 exp=rhs->exponent-exponent; /* RHS padding needed */
4789 /* Calculate units and remainder from exponent. */
4798 /* [exponent is as for original remainder] */
4805 /* Set exponent and bits */
4806 res->exponent=exponent;
4870 Int exponent; /* work */
5153 /* There can be a 31-bit wrap in calculating the exponent. */
5156 /* safe very negative exponent, from which decFinalize() will */
5158 exponent=lhs->exponent+rhs->exponent; /* calculate exponent */
5159 if (lhs->exponent<0 && rhs->exponent<0 && exponent>0)
5160 exponent=-2*DECNUMMAXE; /* force underflow */
5161 res->exponent=exponent; /* OK to overwrite now */
5263 Int h; /* adjusted exponent for 0.xxxx */
5322 /* exponent is such that if x is positive it will have */
5331 d->exponent=-set->digits; /* * 10**(-d) */
5332 if (decNumberIsNegative(rhs)) d->exponent--; /* negative case */
5342 res->exponent=-shift; /* make 1.0000... */
5354 /* calculate the adjusted (Hull & Abrham) exponent (where the */
5356 h=rhs->exponent+rhs->digits;
5368 if (decNumberIsNegative(rhs)) a->exponent=-2; /* make 0.02 */
5385 Int use=-rhs->digits-lever; /* exponent to use for RHS */
5392 if (rhs->exponent!=use) {
5403 newrhs->exponent=use; /* normalize; now <1 */
5476 if (((a->digits+a->exponent)>=(t->digits+t->exponent+p+1))
5538 /* exponent (e=the bottom 2 bits encoding 0-3) */
5675 if (rhs->exponent==0 && set->digits<=40) {
5735 r=rhs->exponent+rhs->digits; /* 'normalised' exponent */
5738 b->exponent=-6; /* .. */
5745 b->exponent=0; /* make integer */
5750 b->exponent=-(t&3)-3; /* set exponent */
5803 (a->digits+a->exponent)>=(b->digits+b->exponent+set->digits+1)) {
5807 if (cmp.lsu[0]==0) a->exponent=0; /* yes, exact 0 */
5812 if (decNumberIsZero(b)) b->exponent=a->exponent-p;
5850 /* decQuantizeOp -- force exponent to requested value */
5853 /* of C (by rounding or shifting) such that the exponent (-scale) */
5854 /* of C has the value B or matches the exponent of B. */
5860 /* rhs is B, the requested exponent */
5868 /* Unless there is an error or the result is infinite, the exponent */
5880 Int reqexp; /* requested exponent [-scale] */
5919 /* set requested exponent */
5920 if (quant) reqexp=inrhs->exponent; /* quantize -- match exponents */
5942 res->exponent=reqexp; /* .. just set exponent */
5948 Int adjust=reqexp-lhs->exponent; /* digit adjustment needed */
5955 if (adjust>0) { /* increasing exponent */
5965 /* If just rounded a 999s case, exponent will be off by one; */
5967 if (res->exponent>reqexp) {
5976 res->exponent--; /* (re)adjust the exponent. */
5982 else /* adjust<=0 */ { /* decreasing or = exponent */
5990 res->exponent+=adjust; /* adjust the exponent */
5997 if (res->exponent>set->emax-res->digits+1) { /* too big */
6139 if (lhs->exponent!=rhs->exponent) {
6140 if (lhs->exponent<rhs->exponent) result=-1;
6144 } /* total-order by exponent */
6157 /* choose according to sign then exponent (see 754) */
6172 if (lhs->exponent<rhs->exponent) result=+1;
6177 if (lhs->exponent>rhs->exponent) result=+1;
6242 if (lhs->exponent>rhs->exponent) { /* LHS exponent larger */
6251 rhs->exponent-lhs->exponent);
6261 /* B has an exponent of E (which must be non-negative) */
6312 /* Calculate units and remainder from exponent. */
6627 /* may be limited if the exponent is high. */
6645 dn->exponent=0; /* (sign is preserved) */
6650 exp=dn->exponent;
6679 Int maxd=set->emax-set->digits+1-dn->exponent;
6686 dn->exponent+=d; /* maintain numerical value */
6886 dest->exponent=src->exponent;
6918 /* dn->digits, dn->lsu (and as required), and dn->exponent are */
6950 /* dn->exponent and residue are unchanged, record any inexactitude */
6956 dn->exponent+=discard; /* maintain numerical value */
7098 /* coefficient constant. The exponent and status are unchanged */
7194 /* and adjust the exponent by one (as otherwise could overflow */
7207 dn->exponent++; /* and bump exponent */
7209 if ((dn->exponent+dn->digits)>set->emax+1) {
7233 dn->exponent--; /* and bump exponent */
7235 /* iff the number was at the subnormal boundary (exponent=etiny) */
7236 /* then the exponent is now out of range, so it will in fact get */
7239 /* dn->exponent, set->digits); */
7240 if (dn->exponent+1==set->emin-set->digits+1) {
7246 dn->exponent++;
7284 dn->exponent=0; /* clean exponent .. */
7288 if (dn->exponent>=0) { /* non-negative exponent */
7290 if (set->digits >= (dn->exponent+dn->digits)) {
7291 dn->digits=decShiftToMost(dn->lsu, dn->digits, dn->exponent);
7292 dn->exponent=0;
7320 /* Must be careful, here, when checking the exponent as the */
7321 /* adjusted exponent could overflow 31 bits [because it may already */
7326 if (dn->exponent<=tinyexp) { /* prefilter */
7330 if (dn->exponent<tinyexp) {
7338 nmin.exponent=set->emin;
7355 if (dn->exponent<=set->emax-set->digits+1) return; /* neither needed */
7359 if (dn->exponent>set->emax-dn->digits+1) { /* too big */
7366 /* here when need to apply the IEEE exponent clamp (fold-down) */
7367 shift=dn->exponent-(set->emax-set->digits+1);
7373 dn->exponent-=shift; /* adjust the exponent to match */
7396 if (dn->exponent>emax) { /* clamp required */
7397 dn->exponent=emax;
7449 dn->exponent=set->emax-set->digits+1;
7453 /* decSetSubnormal -- process value whose exponent is <Emin */
7463 /* Value may be zero with a low exponent; this does not set Subnormal */
7464 /* but the exponent will be clamped to Etiny. */
7466 /* Otherwise ensure exponent is not out of range, and round as */
7484 /* Full arithmetic -- allow subnormals, rounded to minimum exponent */
7486 etiny=set->emin-(set->digits-1); /* smallest allowed exponent */
7496 if (dn->exponent<etiny) { /* clamp required */
7497 dn->exponent=etiny;
7504 adjust=etiny-dn->exponent; /* calculate digits to remove */
7513 /* adjust>0, so need to rescale the result so exponent becomes Etiny */
7526 /* if rounded up a 999s case, exponent will be off by one; adjust */
7528 if (dn->exponent>etiny) {
7530 dn->exponent--; /* (re)adjust the exponent. */
7562 || rhs->exponent+rhs->digits>DEC_MAX_MATH+1
7563 || rhs->exponent+rhs->digits<2*(1-DEC_MAX_MATH))
7587 Int ilength=dn->digits+dn->exponent; /* integral length */
7598 if (ISZERO(dn)) return 0; /* zeros are OK, with any exponent */
7602 if (dn->exponent>=0) { /* relatively easy */
7603 /* no fractional part [usual]; allow for positive exponent */
7604 got=dn->exponent;
7606 else { /* -ve exponent; some fractional part to check and discard */
7607 Int count=-dn->exponent; /* digits to discard */
7762 res->exponent=0; /* clean exponent */
7850 /* Shows: sign, exponent, coefficient (msu first), digits */
7870 /* if coefficient and exponent are 0, no more to do */
7871 if (dn->exponent==0 && dn->digits==1 && *dn->lsu==0) {
7890 if (dn->exponent!=0) {
7892 if (dn->exponent<0) esign='-';
7893 printf(" E%c%ld", esign, (LI)abs(dn->exponent));
8012 if (dn->exponent!=0) {
8014 printf("Exponent %ld (not 0) for a special value [%02x].\n",
8015 (LI)dn->exponent, dn->bits);
8067 /* check the exponent. Note that input operands can have exponents */
8070 ae=dn->exponent+dn->digits-1; /* adjusted exponent */
8076 printf("Adjusted exponent underflow [%ld].\n", (LI)ae);
8082 printf("Adjusted exponent overflow [%ld].\n", (LI)ae);