mirror of https://github.com/apache/cassandra
cqlsh: Improve default float precision behavior
Patch by Stefania Alborghetti; reviewed by Tyler Hobbs for CASSANDRA-9224
This commit is contained in:
parent
744db70146
commit
7f855d113b
|
|
@ -1,4 +1,5 @@
|
|||
2.1.6
|
||||
* (cqlsh) Better float precision by default (CASSANDRA-9224)
|
||||
* Improve estimated row count (CASSANDRA-9107)
|
||||
* Optimize range tombstone memory footprint (CASSANDRA-8603)
|
||||
* Use configured gcgs in anticompaction (CASSANDRA-9397)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import sys
|
||||
import re
|
||||
import time
|
||||
import calendar
|
||||
|
|
@ -144,6 +145,13 @@ def format_floating_point_type(val, colormap, float_precision, **_):
|
|||
elif math.isinf(val):
|
||||
bval = 'Infinity'
|
||||
else:
|
||||
exponent = int(math.log10(abs(val))) if abs(val) > sys.float_info.epsilon else -sys.maxint -1
|
||||
if -4 <= exponent < float_precision:
|
||||
# when this is true %g will not use scientific notation,
|
||||
# increasing precision should not change this decision
|
||||
# so we increase the precision to take into account the
|
||||
# digits to the left of the decimal point
|
||||
float_precision = float_precision + exponent + 1
|
||||
bval = '%.*g' % (float_precision, val)
|
||||
return colorme(bval, colormap, 'float')
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue