MCPcopy Create free account
hub / github.com/cosdata/cosdata / to_float_flag

Function to_float_flag

src/models/common.rs:226–236  ·  view source on GitHub ↗
(x: f32, bits_per_value: usize, step: f32)

Source from the content-addressed store, hash-verified

224
225#[inline]
226fn to_float_flag(x: f32, bits_per_value: usize, step: f32) -> Vec<bool> {
227 let mut n = ((x + 1.0) / step).floor() as usize;
228 let mut result = vec![false; bits_per_value];
229 // Fill the vector with bits from the least significant to the most significant
230 for i in (0..bits_per_value).rev() {
231 result[i] = (n & 1) == 1;
232 n >>= 1;
233 }
234
235 result
236}
237
238pub fn quantize_to_u8_bits(fins: &[f32], resolution: u8) -> Vec<Vec<u8>> {
239 let bits_per_value = resolution as usize;

Callers 1

quantize_to_u8_bitsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected