home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / tutor / l4p140 < prev    next >
Text File  |  1990-07-15  |  4KB  |  109 lines

  1.        ╔════════════════════════════════════════════════════╗
  2.        ║ Lesson 4 Part 140  F-PC 3.5 Tutorial by Jack Brown ║
  3.        ╚════════════════════════════════════════════════════╝
  4.  
  5.  ┌───────────────────────────────────────────────────────────────┐
  6.  │  Some comments on your random case study of lesson 4 part 130 │
  7.  └───────────────────────────────────────────────────────────────┘
  8.  
  9. There are three random number generators provided in part 13.
  10. There is a fourth random number generatorin the file RAND3.SEQ
  11. that comes with the file SMILEY(35).ZIP
  12.  
  13. Compile the code provided lesson 4 part 13 and then execute:
  14.  
  15. CHOOSE BRAND  RANDPLOT <enter>   \ For Brodie's random plot.
  16. CHOOSE TRAND  RANDPLOT <enter>   \ For Tracy's  random plot.
  17. CHOOSE LRAND  RANDPLOT <enter>   \ For Lehmer's random plot.
  18.  
  19. This demo should convince you of the power of human intuition and the
  20. old saying a picture is worth 24000 dots certainly holds true.  At first
  21. the displays being generated should all look pretty random.
  22.  
  23. If at any time you want to halt the display for closer or more detailed
  24. inspection just press any key.  If at this point you decide to abort the
  25. continued display of random dots just press the <enter> key.  Pressing
  26. any key other than <enter> after a temporary halt will cause the
  27. accumulation of more random dots.
  28.  
  29. There are an number of points to consider while watching the different
  30. displays that are generated.
  31.  
  32. 1) If we have a good random number generator then each point on the
  33. screen should have an equal chance to be picked ( displayed as a white
  34. dot).
  35.  
  36. 2) If any random number generator is run long enough...( 10 min to  1
  37. hour ) then evenutally the entire screen will turn white as every pixel
  38. will eventually be lite up.
  39.  
  40. 3) You would think that the more complex Lehmer's generator and that in
  41. the file RAND3.SEQ should be better simply because someone spent more
  42. time on them and there is more code required in their implementation.
  43.  
  44. 4) You would think that a random number generator published in a text
  45. book would have been tested and found not to be lacking in a significant
  46. way.
  47.  
  48. 5) Note that Lehmer's is the only one that generates 32 bit random
  49. numbers directly and hence will be found to be slower because we are
  50. essentially generating a 32 bit random number and truncating it to 16
  51. bits with the word LRAND.
  52.  
  53. ╓──────────────╖
  54. ║ Problem 4.22 ║
  55. ╙──────────────╜
  56. a) Investigate the interesting double number words in the file
  57. DMULDIV.SEQ and the graphics files CGA.SEQ and VGA.SEQ
  58. b) Decide on the basis of the pictorial displays just which random
  59. number generators have serious faults.  I beleive that some of those
  60. four are so bad that they should absolutely never be used for anything!
  61. Your mission is to find out which should never be used!
  62.  
  63.             ┌───────────────────────────────────────┐
  64.             │  Comments on the the file DMULDIV.SEQ │
  65.             └───────────────────────────────────────┘
  66.  
  67. This file provides some some useful double number arithmetic operators.
  68.  
  69. For multiplying two unsigned 32-bit double numbers and yielding an
  70. unsigned 64-bit quad presion result:
  71.  
  72. UMD* ( ud1 ud2 -- uq )  \ uq is the unsigned 64 bit product.
  73.  
  74. For multiplying two signed 32-bit numbers and yielding a 32-bit signed
  75. product:
  76.  
  77. D* ( d1 d2 -- dn ) \ dn is the signed 32 bit product of d1 and d2.
  78.  
  79. Also provided are some mixed precision division operators:
  80.  
  81. For dividing and unsigned 64-bit dividend by an unsigned 32-bit divisor
  82. to yield an unsigned 32-bit quotient and unsigned 32-bit remainder:
  83.  
  84. UMD/MOD ( uqdividend uddivisor -- udremainder udquotient )
  85.  
  86. NOTE: the stack comment in the 2.15 version of the file is wrong!
  87. In that file  the remainder and quotient are reversed.
  88.  
  89. In the case study we gave the definitions for the unsigned operators
  90. UD/MOD  UD/ and UDMOD.
  91.  
  92. We also would like to have signed version of these operators that
  93. conform to signed floored symmetric 32-bit division.  In particular we
  94. need the following:
  95.  
  96. D/MOD ( ddividend ddivisor -- dremainder dquotient )
  97. D/    ( ddividend ddivisor -- dquotient )
  98. DMOD  ( ddividend ddivisor -- dremainder )
  99.  
  100. ╓───────────────╖
  101. ║  Problem 4.23 ║
  102. ╙───────────────╜
  103. Write definitions for the above signed division operators.  Make sure
  104. they conform to symmetric floored division rules!
  105.  
  106. ┌───────────────────────────────────┐
  107. │  Please move to Lesson 4 Part 150 │
  108. └───────────────────────────────────┘
  109.