Tema3 - CHAPTER 3 3.1 Here is a VBA implementation of the...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CHAPTER 3 3.1 Here is a VBA implementation of the algorithm: Option Explicit Sub GetEps() Dim epsilon As Single epsilon = 1 Do If epsilon + 1 <= 1 Then Exit Do epsilon = epsilon / 2 Loop epsilon = 2 * epsilon MsgBox epsilon End Sub It yields a result of 1.19209 × 10 - 7 on my desktop PC. 3.2 Here is a VBA implementation of the algorithm: Option Explicit Sub GetMin() Dim x As Single, xmin As Single x = 1 Do If x <= 0 Then Exit Do xmin = x x = x / 2 Loop MsgBox xmin End Sub It yields a result of 1.4013 × 10 - 45 on my desktop PC. 3.3 The maximum negative value of the exponent for a computer that uses e bits to store the exponent is ) 1 2 ( 1 min - - = - e e Because of normalization, the minimum mantissa is 1/b = 2 - 1 = 0.5. Therefore, the minimum number is 1 1 2 ) 1 2 ( 1 min 2 2 2 - - - - - - = = e e x For example, for an 8-bit exponent 39 128 2 min 10 939 . 2 2 2 1 8 - - - × = = = - x This result contradicts the value from Prob. 3.2 (1.4013 × 10 - 45 ). This amounts to an additional 21 divisions (i.e., 21 orders of magnitude lower in base 2). I do not know the reason for the discrepancy. However, the problem illustrates the value of determining such quantities via a program rather than relying on theoretical values.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
3.4 VBA Program to compute in ascending order
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

Tema3 - CHAPTER 3 3.1 Here is a VBA implementation of the...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online