|
Prev: What does "-1.#J" mean?
Next: Cannot see details in "details view" in Windows Explorer in Vista
From: George on 3 May 2008 05:09 Hello everyone, My question is comes from when I write a C++ program. Not find suitable place to post. :-) My question comes from page 175 of Numerical Computation Guide. Here is a link, http://www.physics.ohio-state.edu/~dws/grouplinks/floating_point_math.pdf I do not know why if β = 2, p = 3, emin = -1 and emax = 2 there are 16 distinct floating-point values in formular (1) in page 174? Are there any more general formular to calculate the distinct value for formular (1) for any given β, p, emin and emax? (sorry, I can not post math formular in this text box) thanks in advance, George
From: Tim Roberts on 4 May 2008 01:12 George <George(a)discussions.microsoft.com> wrote: > >My question is comes from when I write a C++ program. Not find suitable >place to post. :-) > >My question comes from page 175 of Numerical Computation Guide. Here is a >link, > >http://www.physics.ohio-state.edu/~dws/grouplinks/floating_point_math.pdf > >I do not know why if ? = 2, p = 3, emin = -1 and emax = 2 there are >16 distinct floating-point values in formular (1) in page 174? You can enumerate all of the possible values here. With three bits in the mantissa (p=3), you have 4 possible normalized mantissas: 1.00, 1.01, 1.10, 1.11. With emin=-1 and emax=2, there are 4 possible exponents (-1, 0, 1, and 2). Because we are requiring the mantissa to be normalized, each combination is unique: 1.00 x 2^-1 = 0.100 or 0.5 1.01 x 2^-1 = 0.101 or 0.625 1.10 x 2^-1 = 0.110 or 0.75 1.11 x 2^-1 = 0.111 or 0.875 1.00 x 2^0 = 1.00 or 1 1.01 x 2^0 = 1.01 or 1.25 1.10 x 2^0 = 1.10 or 1.5 1.11 x 2^0 = 1.11 or 1.75 1.00 x 2^1 = 10.0 or 2 1.01 x 2^1 = 10.1 or 2.5 1.10 x 2^1 = 11.0 or 3 1.11 x 2^1 = 11.1 or 3.5 1.00 x 2^2 = 100 or 4 1.01 x 2^2 = 101 or 5 1.10 x 2^2 = 110 or 6 1.11 x 2^2 = 111 or 7 You'll see that this matches the notches on the number line. >Are there any more general formular to calculate the distinct value for >formular (1) for any given ?, p, emin and emax? You should be able to figure this out. B^(p-1) x (emax - emin + 1) Why is it (p-1)? Because of the normalization requirement, the top bit is always 1 and therefore wasted. This is why the IEEE 754 floating point format does not store this bit; it assumes the bit is always present. -- Tim Roberts, timr(a)probo.com Providenza & Boekelheide, Inc.
From: George on 4 May 2008 02:35 Hi Tim, You are so smart. Cool!! Two more comments, 1. You use 1.xx other than 0,xx is because in the context, we use normalized form, right? What is the range of the digit in the left of the point in normalized form of float, in base B? [1, B - 1]? 2. But what makes me confused is, suppose you have significant p1 and p2, and the corresponding exponent e1 and e2. Your counting answer is based on the theory that if p1 and p2 are different, no matter what corresponding values are e1 and e2 are, the result must be different. My question is, is it possible that p1 and p2 are different, but also e1 and e2 are different, then p1 * e1 and p2 * e2 produce the same resulting value? regards, George
From: Carl Daniel [VC++ MVP] on 5 May 2008 01:06 George wrote: > Hi Tim, > > > You are so smart. Cool!! > > Two more comments, > > 1. > > You use 1.xx other than 0,xx is because in the context, we use > normalized form, right? > > What is the range of the digit in the left of the point in normalized > form of float, in base B? [1, B - 1]? Yes. > > 2. > > But what makes me confused is, suppose you have significant p1 and > p2, and the corresponding exponent e1 and e2. Your counting answer is > based on the theory that if p1 and p2 are different, no matter what > corresponding values are e1 and e2 are, the result must be different. > > My question is, is it possible that p1 and p2 are different, but also > e1 and e2 are different, then p1 * e1 and p2 * e2 produce the same > resulting value? No, not if the values are normalized. If one or both are denormals then yes, it's possible. -cd
From: George on 6 May 2008 10:00 Cool, cd! Question answered! You are so smart! regards, George
|
Pages: 1 Prev: What does "-1.#J" mean? Next: Cannot see details in "details view" in Windows Explorer in Vista |