Advertisement
Guest User

Documentation is important

a guest
Apr 21st, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.60 KB | None | 0 0
  1. /**
  2.  * Addition of two whole integer numbers. Numbers fed into this function must meet certain requirements in order for proper execution:<br>
  3.  *
  4.  * <b>Case 1:</b> <b><i>a</i></b> is positive, <b><i>b</i></b> is positive.
  5.  * <ul>
  6.  *     <li>a < 2147483647</li>
  7.  *     <li>b < 2147483647</li>
  8.  *     <li>a + b < 2147483647</li>
  9.  * </ul>
  10.  * <b>Case 2:</b> <b><i>a</i></b> is positive, <b><i>b</i></b> is negative.
  11.  * <ul>
  12.  *     <li>a < 2147483647</li>
  13.  *     <li>b > -2147483648</li>
  14.  *     <li>a - b < 2147483647</li>
  15.  *     <li>b - a > -2147483648</li>
  16.  * </ul>
  17.  * <b>Case 3:</b> <b><i>a</i></b> is negative, <b><i>b</i></b> is negative.
  18.  * <ul>
  19.  *     <li>a > -2147483648</li>
  20.  *     <li>b > -2147483648</li>
  21.  *     <li>a + b > -2147483648</li>
  22.  * </ul>
  23.  <b>Case 4:</b> <b><i>a</i></b> is negative, <b><i>b</i></b> is positive.
  24.  * <ul>
  25.  *     <li>a > -2147483648</li>
  26.  *     <li>b < 2147483647</li>
  27.  *     <li>a - b > -2147483648</li>
  28.  *     <li>b - a < 2147483647</li>
  29.  * </ul>
  30.  * <hr>
  31.  * <b>Example Usage:</b>
  32.  * <pre>
  33.  *     // Parameter numbers, pre-verified to match all the conditions required of inputs
  34.  *     int ten = 10; // BIN: 1010
  35.  *     int two = 2;  // BIN: 0010
  36.  *     //
  37.  *     //  1010 = 10
  38.  *     // +0010 = 2
  39.  *     // -----
  40.  *     //  1100 = 12
  41.  *     //
  42.  *     int twelve = add(10, 2);
  43.  * </pre>
  44.  * <hr>
  45.  * <b>Compilation:</b>
  46.  * <pre>
  47.  *   public static add(II)I
  48.  *    L0
  49.  *     ILOAD 0                    // Push "a" to stack        
  50.  *     ILOAD 1                    // Push "b" to stack
  51.  *     IADD                       // Add top two stack values, "a" and "b" respectively, push sum to stack
  52.  *     IRETURN                    // Return "a + b" evaluation
  53.  *    L1
  54.  *     LOCALVARIABLE a I L0 L1 0  // Local var information for "a"
  55.  *     LOCALVARIABLE b I L0 L1 1  // Local var information for "b"
  56.  *     MAXSTACK = 2               // Maximum number of items on the stack in this method at any one point
  57.  *     MAXLOCALS = 2              // Number of local variables used in the method
  58.  * </pre>
  59.  *
  60.  * @param a
  61.  *      The first integer number to add to the second integer number parameter, <b><i>b</i></b>.
  62.  * @param b
  63.  *      The second integer number to add to the first integer number parameter, <b><i>a</i></b>.
  64.  * @return The summation of the two given parameter integers, <b><i>a</i></b>  and <b><i>b</i></b> respectively.
  65.  */
  66. public static int add(int a, int b) {
  67.     // Take two parameter values and use the addition operator as such:
  68.     //   ($V1) + ($V2)
  69.     // Then return the value of the expression for further usage in the caller function.
  70.     return a + b;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement