static Similarity() { { for (int i = 0; i < 256; i++) { NORM_TABLE[i] = SmallFloat.Byte315ToFloat((byte)i); } } }
/// <summary>Encodes a normalization factor for storage in an index. /// /// <p/>The encoding uses a three-bit mantissa, a five-bit exponent, and /// the zero-exponent point at 15, thus /// representing values from around 7x10^9 to 2x10^-9 with about one /// significant decimal digit of accuracy. Zero is also represented. /// Negative numbers are rounded up to zero. Values too large to represent /// are rounded down to the largest representable value. Positive values too /// small to represent are rounded up to the smallest positive representable /// value. /// /// </summary> /// <seealso cref="Mono.Lucene.Net.Documents.Field.SetBoost(float)"> /// </seealso> /// <seealso cref="Mono.Lucene.Net.Util.SmallFloat"> /// </seealso> public static byte EncodeNorm(float f) { return((byte)SmallFloat.FloatToByte315(f)); }