0

Is there a way to define a type of integers, that are only 7 bits long? Or at least 1 byte long? I want to replace standard integers stored in database to reduce the size. I am using mainly those databases: MySQL, Sparksee (for graphs). And those languages: C++, Objective-C++. Is using char instead of int - my best option?

ashvardanian
  • 424
  • 1
  • 6
  • 17

1 Answers1

0

MySQL supports the TINYINT (8 bit), SMALLINT (16 bit), MEDIUMINT (24 bit), INT (32 bit), and BIGINT (64 bit) data types. http://dev.mysql.com/doc/refman/5.7/en/integer-types.html

The corresponding C language data types are int8_t, int16_t, int32_t, and int64_t. There isn't a standard 24-bit data type in C. See this for more information. http://www.nongnu.org/avr-libc/user-manual/group__avr__stdint.html

These are signed data types. So, for example, int8_t has potential values in the range [-128, 127].

You will need a very large number of records in your system for your cost saving from using smaller integers to exceed one dollar US. SSD drives currently cost something less than $0.50 per gigabyte. Best to spend your time and effort elsewhere.

O. Jones
  • 103,626
  • 17
  • 118
  • 172