Skip to main content
10 events
when toggle format what by license comment
Oct 2, 2015 at 16:21 comment added Hannah Vernon For 0-64, you could multiply by 0x100 to store, then & with 0x3F00, and divide by 0x100 to retrieve.
Oct 2, 2015 at 16:18 comment added Hannah Vernon yah, for 0-255 you'd need this to be a BIGINT.
Oct 2, 2015 at 16:17 comment added Solomon Rutzky I was wondering what the multipliers and & values would be to allow each of the 6 parameters to have a range of 0 - 100 or even just 0 - 63. In this model they cannot go up to 255 since that is a full byte, and there are only 4 bytes in an INT yet 6 parameters. That is why I was curious about how to handle some type of middle-ground.
Oct 2, 2015 at 15:38 comment added Hannah Vernon I'm not certain I follow you, but if you wanted to have values up to 255, I would do it by making the multipliers like 0x1, 0x100, 0x10000, etc. The logical AND values (the &) would be 0xFF, 0xFF00, 0xFF0000, etc.
Oct 2, 2015 at 15:22 comment added Solomon Rutzky You could increase beyond 0 - 15 by adjusting the shifts to 0x20, 0x200, etc?
Oct 2, 2015 at 15:07 comment added Hannah Vernon Agreed, @srutzky - you could use TINYINT fields, as you've said. However, the design I've proposed allows the OP to easily increase the range of values for each of the 6 sets. Also, agreed about the need for the ID field; unless you were using the entire set each time you access the table.
Oct 2, 2015 at 14:54 comment added Solomon Rutzky You could further reduce the size by storing the values in 3 TINYINT fields since you are only using 3 of the 4 bytes of the INT. Each TINYINT would represent 2 of the parameters (1 and 2, 3 and 4, and 5 and 6). And each value only needs the no-shift and 0x10 shift. Also, the ID field is needed since if there was no need to reference the values again, then no table was needed in the first place and the query to generate the values to populate the table would have sufficed. Right?
Oct 2, 2015 at 3:13 history edited Hannah Vernon CC BY-SA 3.0
added 12 characters in body
Oct 2, 2015 at 2:31 history edited Hannah Vernon CC BY-SA 3.0
added 132 characters in body
Oct 2, 2015 at 2:21 history answered Hannah Vernon CC BY-SA 3.0