Skip to content Skip to sidebar Skip to footer

Mysql Finding Min/max Values For Double

The relevant MySQL documentation states that for doubles: Permissible values are -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.79769313

Solution 1:

If you want to find and prove you know the exact max value on a system, here is a way to do it in a few minutes of execution time.

Do a simple loop that starts with the value of 1 and inserts it. On each loop multiple the value by 10 until it fails on overflow. At the end of this you have the minWorkingValue and the maxFailedValue.

Now do a second loop that inserts a value halfway between minWorkingValue and maxFailedValue. If it succeeds it becomes the new minWorkingValue. If it fails it becomes the new maxFailedValue. Continue until maxFailedValue - minWorkingValue = 1. At the end minWorkingValue is your actual max value you can insert.

As an alternative, if you are pretty sure you know where these values might be, then skip the first step and manually set minWorkingValue and maxFailedValue and straight to the 2nd loop.

Post a Comment for "Mysql Finding Min/max Values For Double"