|
Prev: Which direction is Fortran going?
Next: What's the meaning of "a model set of integers (reals)" in Fortran?
From: hermitian on 2 Feb 2008 00:06 Hi, everyone. I'm reading a book titled "Fortran 90/95 Explained" to learn Fortran by myself. My major is chemistry, so this question might be silly. In section 8.7.1 models for integer and real data. The authors wrote: For each kind of integer, it is the set i = s \times \sum_{k=1}^{q} w_k \times r^{k-1} For each kind of real, it is the set x = 0 and x = s \times b^e \time \sum_{k=1}^{p} f_k \times b^{-k} I am puzzled about the models. Could anyone give me more detailed information or some examples on the models? For example, how about the models for an integer 5 and a floating-number 5.0! Any helps are appreciated! Thank you!
From: glen herrmannsfeldt on 2 Feb 2008 00:45 hermitian wrote: > In section 8.7.1 models for integer and real data. The authors wrote: > For each kind of integer, it is the set > i = s \times \sum_{k=1}^{q} w_k \times r^{k-1} This means q digit integers in base r. > For each kind of real, it is the set > x = 0 > x = s \times b^e \time \sum_{k=1}^{p} f_k \times b^{-k} This means base b floating point with p digits of precision. On most machines today r and b are two, but the standard allows for other bases. q is often 31, and p is often 24 or 53. -- glen
From: hermitian on 2 Feb 2008 01:32 Thank you, Glen! > On most machines today r and b are two, but the standard > allows for other bases. q is often 31, and p is often > 24 or 53. I also learned that s is \pm 1 and if r is two and q is 31, the model for positive integer is: i = \sum_{k=1}^{31} k_w \times 2^{k-1} where k_w might be zero or one. But, how can I expand a positive integer, i.e. 5, in terms of this formula? For instance, the left side of the aforementioned formula is 5. How about the right side of the formula? 5 = ??? One more question, does every k_w (zero or one) correspond to the computer bit (zero or one) used to store the integer?
From: andy2O on 1 Feb 2008 03:31 On Feb 1, 6:32 am, hermitian <iamwu...(a)gmail.com> wrote: > Thank you, Glen! > > > On most machines today r and b are two, but the standard > > allows for other bases. q is often 31, and p is often > > 24 or 53. > > I also learned that s is \pm 1 and if r is two and q is 31, the model > for positive integer is: > > i = \sum_{k=1}^{31} k_w \times 2^{k-1} > > where k_w might be zero or one. But, how can I expand a positive > integer, i.e. 5, in terms of this formula? For instance, the left side > of the aforementioned formula is 5. How about the right side of the > formula? > > 5 = ??? > > One more question, does every k_w (zero or one) correspond to the > computer bit (zero or one) used to store the integer? OK, using the formula as you wrote it, and note from your maths books note that 2^0 = 1, so: 5 = 4 + 1 = 2^2 + 2^0 So to get 5, set k_w = 0 for all w *except* for w=1 and 3 which have k_1 = k_3 = 1. In general this looks like: i = k_1 * 2^0 + k_2 * 2^1 + k_3 * 2^2 + k_4 * 2^3 + k_5 * 2^4 + ... = k_1 * 1 + k_2 * 2 + k_3 * 4 + k_4 * 8 + k_5 * 16 + ... and that will get you all integers in a certain range. Hope that helps. andy
From: robert.corbett on 1 Feb 2008 05:40
On Jan 31, 9:06 pm, hermitian <iamwu...(a)gmail.com> wrote: > Hi, everyone. I'm reading a book titled "Fortran 90/95 Explained" to > learn Fortran by myself. My major is chemistry, so this question might > be silly. > > In section 8.7.1 models for integer and real data. The authors wrote: > > For each kind of integer, it is the set > > i = s \times \sum_{k=1}^{q} w_k \times r^{k-1} > > For each kind of real, it is the set > > x = 0 > > and > > x = s \times b^e \time \sum_{k=1}^{p} f_k \times b^{-k} > > I am puzzled about the models. Could anyone give me more detailed > information or some examples on the models? The model sets are sets of values that "best fit" the different representation methods of the integer and real types. The parameters that characterize the model sets are used to define the values of the numeric inquiry functions. The definition of the function HUGE is a good example to study. > For example, how about the > models for an integer 5 and a floating-number 5.0! Any helps are > appreciated! The model sets are sets. The integer 5 might be a member of the model set of integers for a particular representation method. To date, the Fortran committee has interpreted the phrase "best fit" in a liberal manner. In particular, the model set for a given representation method need not contain all the values that that representation method can represent, and, more controversially, the representation method need not be able to represent all of the elements of the model set. Bob Corbett |