<jupyter_start><jupyter_text>enc/dec fp - snorm<jupyter_code>dtypes = (np.float16, np.uint8)
nbits = 5

fp = np.array([-1., -0.25, -0., 0., 0.25, 1.], dtype=dtypes[0])
print('fp', fp)
print('-'*10)

# std
enc = encode_fp_to_std_snorm(fp, dtype=dtypes[1], nbits=nbits)
dec = decode_std_snorm_to_fp(enc, dtype=dtypes[0], nbits=nbits)

print('std version:')
print('enc', vhex(enc))
print('dec', dec)
print('-'*10)

# ogl
enc = encode_fp_to_ogl_snorm(fp, dtype=dtypes[1], nbits=nbits)
dec = decode_ogl_snorm_to_fp(enc, dtype=dtypes[0], nbits=nbits)

print('ogl version:')
print('enc', vhex(enc))
print('dec', dec)
print('-'*10)

# d3d
enc = encode_fp_to_d3d_snorm(fp, dtype=dtypes[1], nbits=nbits)
dec = decode_d3d_snorm_to_fp(enc, dtype=dtypes[0], nbits=nbits)

print('d3d version:')
print('enc', vhex(enc))
print('dec', dec)
print('-'*10)
dtypes = (np.float32, np.uint16)
nbits = 10

fp = np.array([-1., -0.25, -0., 0., 0.25, 1.], dtype=dtypes[0])
print('fp', fp)
print('-'*10)

# std
enc = encode_fp_to_std_snorm(fp, dtype=dtypes[1], nbits=nbits)
dec = decode_std_snorm_to_fp(enc, dtype=dtypes[0], nbits=nbits)

print('std version:')
print('enc', vhex(enc))
print('dec', dec)
print('-'*10)

# ogl
enc = encode_fp_to_ogl_snorm(fp, dtype=dtypes[1], nbits=nbits)
dec = decode_ogl_snorm_to_fp(enc, dtype=dtypes[0], nbits=nbits)

print('ogl version:')
print('enc', vhex(enc))
print('dec', dec)
print('-'*10)

# d3d
enc = encode_fp_to_d3d_snorm(fp, dtype=dtypes[1], nbits=nbits)
dec = decode_d3d_snorm_to_fp(enc, dtype=dtypes[0], nbits=nbits)

print('d3d version:')
print('enc', vhex(enc))
print('dec', dec)
print('-'*10)
dtypes = (np.float64, np.uint32)
nbits = 20

fp = np.array([-1., -0.25, -0., 0., 0.25, 1.], dtype=dtypes[0])
print('fp', fp)
print('-'*10)

# std
enc = encode_fp_to_std_snorm(fp, dtype=dtypes[1], nbits=nbits)
dec = decode_std_snorm_to_fp(enc, dtype=dtypes[0], nbits=nbits)

print('std version:')
print('enc', vhex(enc))
print('dec', dec)
print('-'*10)

# ogl
enc = encode_fp_to_ogl_snorm(fp, dtype=dtypes[1], nbits=nbits)
dec = decode_ogl_snorm_to_fp(enc, dtype=dtypes[0], nbits=nbits)

print('ogl version:')
print('enc', vhex(enc))
print('dec', dec)
print('-'*10)

# d3d
enc = encode_fp_to_d3d_snorm(fp, dtype=dtypes[1], nbits=nbits)
dec = decode_d3d_snorm_to_fp(enc, dtype=dtypes[0], nbits=nbits)

print('d3d version:')
print('enc', vhex(enc))
print('dec', dec)
print('-'*10)<jupyter_output>fp [-1.   -0.25 -0.    0.    0.25  1.  ]
----------
std version:
enc ['0xfffff' '0x40001' '0x1' '0x0' '0x40000' '0xffffe']
dec [-1.         -0.25000048 -0.          0.          0.25000048  1.        ]
----------
ogl version:
enc ['0x80001' '0xe0000' '0x0' '0x0' '0x20000' '0x7ffff']
dec [-1.         -0.25000048  0.          0.          0.25000048  1.        ]
----------
d3d version:
enc ['0x80001' '0xe0000' '0x0' '0x0' '0x20000' '0x7ffff']
dec [-1.         -0.25000048  0.          0.          0.25000048  1.        ]
----------
{'fraction_non_alphanumeric': 0.21810139503232392, 'fraction_numerical': 0.08302143586253828, 'mean_word_length': 4.326086956521739, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '661174', 'license': 'MIT', 'n_tokens_mistral': 1458, 'n_tokens_neox': 1353, 'n_words': 248, 'path': 'example/enc_dec_xxx_snorm.ipynb', 'repo_name': 'Hasenpfote/fpq', 'size': '2939'}