MCPcopy Create free account
hub / github.com/devosoft/avida / AsInt

Method AsInt

avida-core/source/cpu/cCodeLabel.cc:80–90  ·  view source on GitHub ↗

Translates a code label into an n-ary integer, reading the first nop as 0. * Example: nops A, B, C with base 3 * no nops = 0 * A = 0 * B = 1 * AA = 0 * AC = 2 * BB = 4 * CA = 6 */

Source from the content-addressed store, hash-verified

78 * CA = 6
79 */
80int cCodeLabel::AsInt(const int base) const
81{
82 int value = 0;
83
84 for (int i = 0; i < m_nops.GetSize(); i++) {
85 value *= base;
86 value += m_nops[i];
87 }
88
89 return value;
90}
91
92int cCodeLabel::AsIntGreyCode(const int base) const
93{

Calls 1

GetSizeMethod · 0.45

Tested by

no test coverage detected