Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL min/max for DOUBLE type

Tags:

mysql

double

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.

like image 814
Matty Avatar asked Aug 04 '11 23:08

Matty


1 Answers

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.

like image 160
paxdiablo Avatar answered Oct 11 '22 23:10

paxdiablo