I understand that some operations are guaranteed to be always exact when their result is very small, but what exactly is the threshold of the result under which they become exact ? I'm using the round-to-nearest mode.

Daniel Aioanei

6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Since no one has undertaken to guess what you're referring to, I'll assume you're talking about the IEEE inexact flag for floating point arithmetic. Using the EPSILON intrinsics defined in C and Fortran standards, you could make certain statements, for example:
Adding 1 to an integral value, of value <= 1/EPSILON, does not raise the inexact flag. Evidently, this may have no relationship to your question, so I'll stop there.

Actually, I'm trying to implement directed rounding in Java, where I have no access to the status flags, and the only available rounding mode is to-nearest. Knowing that certain operations are exact would be helpful.

I'm not sure what you mean here either. Floating point arithmatic uses a finite set of bits to try and represent an infinite set of numbers. It is not the operations that are or are not exact, it is the numbers themselves. Numbers that are multiples of small negative powers of two are exact. For example, .5 and its multiples can be represented exactly because it is 2^-1. A multiple of .25 can also be represented exactly, because it is 2^-2. This exactness is only for "small numbers" -- I'm not sure where the cutoff is, but 439.75 is an exact floating point number so it isn't extremely small. A number like .1 cannot be represented exactly in floating point -- there is simply no way to do it, even with a massive number of bits. If you're looking for exactness, a better option would be fixed-point decimal. I believe the Java library class BigDecimal represents a fixed-point decimal number, so you might not even have to do any work yourself to get it ;). Fixed-point should maintain exactness for all operations but division.

Thanks for your response. Actually I need directed rounding control in order to implement interval and affine arithmetic.

I found what I was looking for in the appendix of the http://citeseer.nj.nec.com/hauser96handling.html white paper, Theorems 3.4.1 and 3.4.2.

Leave a Comment

Please sign in to add a comment. Not a member? Join today