public static double DecodeBinary(BinaryRepresentation binaryRepresentation, DomainDefinition domainDefinition, int precision) { var d = Convert.ToInt64(binaryRepresentation.AsString(), 2); var bitsNumber = BitsNumberForDomainDimension(domainDefinition, precision); return((domainDefinition.End - domainDefinition.Start) * (d / (Pow(2, bitsNumber) - 1)) + domainDefinition.Start); }
private static IEnumerable <BinaryRepresentation> GetAlteredRepresentations(BinaryRepresentation bitRepresentation) { return(bitRepresentation.Bits.Select((bit, index) => { var alteredBit = bit == '0' ? '1' : '0'; var alteredRepresentation = new StringBuilder(bitRepresentation.AsString()); alteredRepresentation[index] = alteredBit; return BinaryRepresentation.Create(alteredRepresentation.ToString()); })); }