Class ExponentialCornerCases

java.lang.Object
edu.gvsu.kurmasz.warszawa.listgen.IntegerListGenerator
edu.gvsu.kurmasz.warszawa.listgen.ExponentialCornerCases
Direct Known Subclasses:
CornerCases

public class ExponentialCornerCases
extends IntegerListGenerator
Generate lists of integers that represent values surrounding powers of 2 (using exponents for parameters). (Such values are often "corner cases" when testing circuits.) This class is similar to CornerCases, except the parameters refer to exponents instead of actual values. For example, ExponentailCornerCases.getLongArray(5, 7, 1) produces the same list as CornerCases.getLongArray(32, 127, 1).
Author:
Zachary Kurmas
  • Constructor Summary

    Constructors 
    Constructor Description
    ExponentialCornerCases()  
  • Method Summary

    Modifier and Type Method Description
    long[] generateLongArray​(long start, long stop, long step)
    Generate an array of long integers containing the values surrounding powers of two.

    Methods inherited from class edu.gvsu.kurmasz.warszawa.listgen.IntegerListGenerator

    generateIntArray, generateIntList, generateLongList

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • generateLongArray

      public long[] generateLongArray​(long start, long stop, long step)
      Generate an array of long integers containing the values surrounding powers of two. For this class, the user uses exponents to specify the values at which the sequence is to begin and end. For each exponent i specified (except the first and last), the values (2^i)-1, 2^i, and (2^i)+1 are included in the output.

      The first and last exponents behave differently: (2^{start})-1 is not included. Similarly The last value in the list will be (2^stop)-1. (In other words, 2^stop, and (2^stop)+1 are not included.) These rules allow the user to use the minimum and maximum widths of the desired values as the start and stop parameters. For example, when testing a 64-bit adder, using 64 as the stop parameter will specify that the last value is (2^64)-1: the maximum value that can be represented with 64 bits.

      Negative parameter values are treated specially: If start is -4, the first value will be -(2^|start|) = -16 (because 2^-4 is not an integer).

      Specified by:
      generateLongArray in class IntegerListGenerator
      Parameters:
      start - the exponent of the first desired value. (See comment above.) Also, -64start64 (otherwise the resulting values won't be Java longs).
      stop - the exponent of the last desired value. (See comment above.) Must be >= start. The value(2^stop)-1 will always appear in the list, even if step would otherwise cause it to be skipped. stop must be >= start. Also, -64stop64 (otherwise the resulting values won't be Java longs).
      step - the value by which the exponent is incremented. Must be >= 1. (See comment for stop parameter.)
      Returns:
      an array of long integers.
      Throws:
      java.lang.IllegalArgumentException - if the parameter values specify either (1) a value that is outside the range of a Java long, or (2) more values than can be stored in a single array.