Fernando Cacciola wrote: > > OK. > So, correct me if I'm wrong: > For any given decimal with some int_type, a 'digits' constant is > associated with it which comes from numeric_limits<int_type>::digits10. > This constant identifies the maxium number of digits (in both the > whole and fractional parts) that any such decimal can represent. >
Right, it's the /precision/ (the total number of representable digits). Consider, for example, numeric_limits<int>::digits10 on an implementation with 32-bit ints. This value will be 9 because all 9-digit values are representable. There will also be some some 10-digit values that are representable (if the MSD is in [-2,2]). > > Thus numeric_limits<decimal>::digits and digits10 are equal to > this constant. > Yes, and the two values are equal to each other because numeric_limits<decimal>::radix is 10. > > The scale 's' given by the user specifies the desired number of > decimal digits. > I would say "digits to the right of the decimal point". (Digits to the left of the point I would also call "decimal" because they're base-10.) > > It cannot be > '(digits-1'), ... > Yes, the scale can be equal to the precision (which I believe is what you're calling "digits"); but then, in general, there won't be any digits to the left of the point. (As with the example above with numeric_limits<int>::digits10, there could be one valid digit to the left of the point if it's not too large.) > > I'd put a description like the one above in the docs so that the > limit on total number of digits and its relation with the scale > is well documented. > Agreed. > > > > Why? [can't decimal be unbounded] > > > Because it has a constant max_scale. > Ah, so. Yes, I see that now. Good catch. > > > > I don't see this. If int_type just wraps around on overflow, > > then why wouldn't the decimal type itself do the same? > > Because decimal has its own arithmetic. > For instance, would decimal::add/mul wrap around even if > int_type would? Yes, I think you're right about that. OK, is_bounded should be true and is_modulo should be false. I'll fix that. Re the max_val, min_val and max_scale constants: there was some reason that I wanted them to be constant expressions. I'll reconsider that; but I don't want to promise a change right now. Re construction from unsigned int: I think you gave a good reason to allow it. I'm pretty busy at my day job right now, so I can't promise a quick change; but I agree with you. > > If the concept of 'digits' is formalized, alon with its relation > to 'scale', then this statement could simply say that "The conversion > will be exact if the string contains no more than 'digits()' digits > (whole and/or decimal)" > I don't think that's right. I can assign 123.45 to a decimal with a scale of 2 without rounding. Do I misunderstand what you're saying? --Bill Seymour _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost