Skip to content

defines a byte as a mantissa of (4 + 1) bits and shift of 4 bits

Notifications You must be signed in to change notification settings

LabZDjee/compressIntToByte

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

compressIntToByte.c

Defines a byte (unsigned char) as a shift of 4 bits and a mantissa of (4 + 1) bits (additional 1 bit is a hidden leading bit as defined by IEEE 754 for floats)

Encodes values from 0 to 516,095 with a 3 % accuracy (1/32) encoding scheme:

  • shift is 0 -> mantissa
  • otherwise -> (0x10 + mantissa) << (shift - 1)

Shift is encoded as bits b7 to b4 in byte and mantissa as bits b3 to b0

Here is a table of the decoded values for mantissa from 0 to 15 (in columns) and shift values from 0 to 15 (in lines)

sh:0       0      1      2      3      4      5      6      7      8      9     10     11     12     13     14     15
sh:1 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
sh:2 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62
sh:3 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120 124
sh:4 128 136 144 152 160 168 176 184 192 200 208 216 224 232 240 248
sh:5 256 272 288 304 320 336 352 368 384 400 416 432 448 464 480 496
sh:6 512 544 576 608 640 672 704 736 768 800 832 864 896 928 960 992
sh:7 1024 1088 1152 1216 1280 1344 1408 1472 1536 1600 1664 1728 1792 1856 1920 1984
sh:8 2048 2176 2304 2432 2560 2688 2816 2944 3072 3200 3328 3456 3584 3712 3840 3968
sh:9 4096 4352 4608 4864 5120 5376 5632 5888 6144 6400 6656 6912 7168 7424 7680 7936
sh:10 8192 8704 9216 9728 10240 10752 11264 11776 12288 12800 13312 13824 14336 14848 15360 15872
sh:11 16384 17408 18432 19456 20480 21504 22528 23552 24576 25600 26624 27648 28672 29696 30720 31744
sh:12 32768 34816 36864 38912 40960 43008 45056 47104 49152 51200 53248 55296 57344 59392 61440 63488
sh:13 65536 69632 73728 77824 81920 86016 90112 94208 98304 102400 106496 110592 114688 118784 122880 126976
sh:14 131072 139264 147456 155648 163840 172032 180224 188416 196608 204800 212992 221184 229376 237568 245760 253952
sh:15 262144 278528 294912 311296 327680 344064 360448 376832 393216 409600 425984 442368 458752 475136 491520 507904
Note: negative values cannot be encoded

About

defines a byte as a mantissa of (4 + 1) bits and shift of 4 bits

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages