jenes.chromosome.codings
Class ShortCoding

java.lang.Object
  extended by jenes.chromosome.BitwiseChromosome.BitCoding<java.lang.Integer>
      extended by jenes.chromosome.codings.ShortCoding

public class ShortCoding
extends BitwiseChromosome.BitCoding<java.lang.Integer>

Represents a short coding with 16 bits. There are two possible representations: the two complement ond and the module and sign one. The range representable with the former is [-32768,32767]; the one representable with the latter is [-32767,32767] (the difference is the latter provides two different codes to represent the 0).

Since:
1.0
Version:
1.2
Author:
Luigi Troiano, Pierpaolo Lombardi, Giuseppe Pascale, Thierry Bodhuin
See Also:
ByteCoding, IntCoding, GrayCoding, WordCoding, BitwiseChromosome.BitSize, BooleanCoding

Nested Class Summary
static class ShortCoding.Mode
          The integer coding representations
 
Field Summary
 
Fields inherited from class jenes.chromosome.BitwiseChromosome.BitCoding
SIZE
 
Constructor Summary
ShortCoding()
          Default constructor.
ShortCoding(ShortCoding.Mode mode)
          Creates a ShortCoding with the specified mode, that is the number representation scheme.
 
Method Summary
 java.lang.Integer decode(int bits)
          Returns the value of coded bits
 int encode(java.lang.Integer value)
          Returns the bits coding the value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShortCoding

public ShortCoding()
Default constructor. The default mode is two's complement.


ShortCoding

public ShortCoding(ShortCoding.Mode mode)
Creates a ShortCoding with the specified mode, that is the number representation scheme.

Parameters:
mode - can be two's complement or module and sign.
Method Detail

decode

public final java.lang.Integer decode(int bits)
Returns the value of coded bits

Specified by:
decode in class BitwiseChromosome.BitCoding<java.lang.Integer>
Parameters:
bits - coding the value
Returns:
the value

encode

public final int encode(java.lang.Integer value)
Returns the bits coding the value

Specified by:
encode in class BitwiseChromosome.BitCoding<java.lang.Integer>
Parameters:
value - the value to be coded
Returns:
the coding bits