You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
4.5 KiB

1 year ago
  1. ***********************
  2. The CS:APP Data Lab
  3. Directions to Students
  4. ***********************
  5. Your goal is to modify your copy of bits.c so that it passes all the
  6. tests in btest without violating any of the coding guidelines.
  7. *********
  8. 0. Files:
  9. *********
  10. Makefile - Makes btest, fshow, and ishow
  11. README - This file
  12. bits.c - The file you will be modifying and handing in
  13. bits.h - Header file
  14. btest.c - The main btest program
  15. btest.h - Used to build btest
  16. decl.c - Used to build btest
  17. tests.c - Used to build btest
  18. tests-header.c- Used to build btest
  19. dlc* - Rule checking compiler binary (data lab compiler)
  20. driver.pl* - Driver program that uses btest and dlc to autograde bits.c
  21. Driverhdrs.pm - Header file for optional "Beat the Prof" contest
  22. fshow.c - Utility for examining floating-point representations
  23. ishow.c - Utility for examining integer representations
  24. ***********************************************************
  25. 1. Modifying bits.c and checking it for compliance with dlc
  26. ***********************************************************
  27. IMPORTANT: Carefully read the instructions in the bits.c file before
  28. you start. These give the coding rules that you will need to follow if
  29. you want full credit.
  30. Use the dlc compiler (./dlc) to automatically check your version of
  31. bits.c for compliance with the coding guidelines:
  32. unix> ./dlc bits.c
  33. dlc returns silently if there are no problems with your code.
  34. Otherwise it prints messages that flag any problems. Running dlc with
  35. the -e switch:
  36. unix> ./dlc -e bits.c
  37. causes dlc to print counts of the number of operators used by each function.
  38. Once you have a legal solution, you can test it for correctness using
  39. the ./btest program.
  40. *********************
  41. 2. Testing with btest
  42. *********************
  43. The Makefile in this directory compiles your version of bits.c with
  44. additional code to create a program (or test harness) named btest.
  45. To compile and run the btest program, type:
  46. unix> make btest
  47. unix> ./btest [optional cmd line args]
  48. You will need to recompile btest each time you change your bits.c
  49. program. When moving from one platform to another, you will want to
  50. get rid of the old version of btest and generate a new one. Use the
  51. commands:
  52. unix> make clean
  53. unix> make btest
  54. Btest tests your code for correctness by running millions of test
  55. cases on each function. It tests wide swaths around well known corner
  56. cases such as Tmin and zero for integer puzzles, and zero, inf, and
  57. the boundary between denormalized and normalized numbers for floating
  58. point puzzles. When btest detects an error in one of your functions,
  59. it prints out the test that failed, the incorrect result, and the
  60. expected result, and then terminates the testing for that function.
  61. Here are the command line options for btest:
  62. unix> ./btest -h
  63. Usage: ./btest [-hg] [-r <n>] [-f <name> [-1|-2|-3 <val>]*] [-T <time limit>]
  64. -1 <val> Specify first function argument
  65. -2 <val> Specify second function argument
  66. -3 <val> Specify third function argument
  67. -f <name> Test only the named function
  68. -g Format output for autograding with no error messages
  69. -h Print this message
  70. -r <n> Give uniform weight of n for all problems
  71. -T <lim> Set timeout limit to lim
  72. Examples:
  73. Test all functions for correctness and print out error messages:
  74. unix> ./btest
  75. Test all functions in a compact form with no error messages:
  76. unix> ./btest -g
  77. Test function foo for correctness:
  78. unix> ./btest -f foo
  79. Test function foo for correctness with specific arguments:
  80. unix> ./btest -f foo -1 27 -2 0xf
  81. Btest does not check your code for compliance with the coding
  82. guidelines. Use dlc to do that.
  83. *******************
  84. 3. Helper Programs
  85. *******************
  86. We have included the ishow and fshow programs to help you decipher
  87. integer and floating point representations respectively. Each takes a
  88. single decimal or hex number as an argument. To build them type:
  89. unix> make
  90. Example usages:
  91. unix> ./ishow 0x27
  92. Hex = 0x00000027, Signed = 39, Unsigned = 39
  93. unix> ./ishow 27
  94. Hex = 0x0000001b, Signed = 27, Unsigned = 27
  95. unix> ./fshow 0x15213243
  96. Floating point value 3.255334057e-26
  97. Bit Representation 0x15213243, sign = 0, exponent = 0x2a, fraction = 0x213243
  98. Normalized. +1.2593463659 X 2^(-85)
  99. linux> ./fshow 15213243
  100. Floating point value 2.131829405e-38
  101. Bit Representation 0x00e822bb, sign = 0, exponent = 0x01, fraction = 0x6822bb
  102. Normalized. +1.8135598898 X 2^(-126)