MySQL min/max for DOUBLE type

2019-04-30 10:54发布

The MySQL documentation for the DOUBLE type is really opaque as to what the minimum and maximum values are.

Permissible values are -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.7976931348623157E+308.

This doesn't make sense to me. Maybe I'm being a mathtard, but I'm not understanding this. There appears to be two possible ranges and zero.

标签: mysql double
2条回答
Bombasti
2楼-- · 2019-04-30 11:32

The closest Double to zero is

2.2250738585072014E-308 positive

-2.2250738585072014E-308 negative

查看更多
时光不老,我们不散
3楼-- · 2019-04-30 11:54

Yes, it has a range of possible positive values, zero, and a range of possible negative values.

The reason they're doing it that way is to ensure you get both the maximum and minimum possible numbers on either side of zero.

Alternatively, they could state that the range is -1.7976931348623157E+308 through 1.7976931348623157E+308 but that doesn't give you any information about the numbers closest to zero that they can represent. (the ones with the -308 exponent) and you may think you can represent 1E-999 (which you can't).

For the unsigned variant, it just disallows the negative range, which is possibly another reason why they specified the two ranges separately - you can just ignore the negative range totally in that case.

查看更多
登录 后发表回答