This certainly sounds like a reasonable approach to me...
Edward
At 09:49 AM 8/15/2005 -0600, Michael J. Wirthlin wrote:
Thanks for the feedback - this has been a good discussion on Fixed Point
and I am glad to hear that there are others interested in this functionality.
I want to follow up on the conversation with a couple of comments and
suggestions for change. The "bit-growth" behavior is inconsistent for
multiply and add. Multiply operations apply bit growth while add does not.
No matter what approach is chosen for handling bit-growth/overflow in the
FixPoint class, I believe that the behavior should be consistent among all
of the operations.
I suggest that we provide more than one function for each arithmetic
operation. One of the functions would perform the operation lossless (i.e.
allow bit-growth as necessary to preserve full arithmetic result). The
other function would perform the operation with a user-specified
quantization. This function would return a result in the quantization
specified by the user and using the rounding/overflow specified by the
user to obtain the result. Here are the two function prototypes for add:
/** Perform addition with the user-supplied quantization */
FixPoint.add(FixPoint t, FixPointQuantization q)
/** Perform lossless addition */
FixPoint.add(FixPoint t)
It is intersting to note that the division operation already has two
functions. One provides user-specified quantization and the other does
not. Since it is not possible to perform lossless division, the divide
operation that does not provide user-specified quantization is not
lossless. This operation insures that the result has as much precision as
the operand with the most precision (i.e. most fractional bits).
Any other thoughts or suggestions?
- Mike
--
Michael J. Wirthlin
Associate Professor
Electrical and Computer Engineering Voice: (801) 422-7601
Brigham Young University Fax: (801) 422-0201
459 Clyde Building Email: [EMAIL PROTECTED]
Provo, UT 84602 www.ee.byu.edu/faculty/wirthlin
----------------------------------------------------------------------------
Posted to the ptolemy-hackers mailing list. Please send administrative
mail for this list to: [EMAIL PROTECTED]
------------
Edward A. Lee
Professor, Chair of the EE Division, Associate Chair of EECS
231 Cory Hall, UC Berkeley, Berkeley, CA 94720
phone: 510-642-0253 or 510-642-0455, fax: 510-642-2845
[EMAIL PROTECTED], http://ptolemy.eecs.berkeley.edu/~eal
----------------------------------------------------------------------------
Posted to the ptolemy-hackers mailing list. Please send administrative
mail for this list to: [EMAIL PROTECTED]