Appropriate datatype for holding percent values?

前端 未结 5 1670
夕颜
夕颜 2020-12-22 23:39

What is the best datatype for holding percent values ranging from 0.00% to 100.00%?

5条回答
  •  有刺的猬
    2020-12-22 23:53

    If 2 decimal places is your level of precision, then a "smallint" would handle this in the smallest space (2-bytes). You store the percent multiplied by 100.

    EDIT: The decimal type is probably a better match. Then you don't need to manually scale. It takes 5 bytes per value.

提交回复
热议问题