Is it possible to format DECIMAL values in Result Grid without trailing zeros?

anti_tenzor's profile image anti_tenzor posted 3 years ago in General Permalink

Hello, thank you for a nice DB manager. =)

I think this question was discussed already and has some simple solution.

I connect to MariaDB and in the Result Grid there is huge amount of trailing zeros for DECIMAL values.

For example, query " SELECT Col1 FROM SomeTable " displays values

95.0000000000000000

and even

0.0000000000000000

Is it possible to remove unnecessary trailing zeros? They take huge amount of space on the screen. =(

In Tools --> Preferences --> Grid formatting there is an option to change color of REAL numbers. Is there some way to specify custom formatting for displayed text?

In C# language I'd use format "0.0###########". This format always displays single digit after the dot (to mark this value is REAL). But it cuts all unnecessary trailing zeros.

Thank you in advance!

ansgar's profile image ansgar posted 3 years ago Permalink

Had the same issue some months ago. My favourite workaround is to add 0e0 to the columns value:

SELECT Col1 + 0e0 FROM SomeTable;

See the difference when you add 0 instead:

untimed + 0e0 untimed + 0
0 0,000
25,328 25,328
217,42 217,420

I think I should add some option to HeidiSQL which does the same without that workaround.

Code modification/commit c8ecee8 from Ansgar Becker <anse@heidisql.com>, 3 years ago, revision 11.3.0.6395
Add user option to cut floats from trailing decimal zeros, and leave 1 zero by default. See https://www.heidisql.com/forum.php?t=38775
ansgar's profile image ansgar posted 3 years ago Permalink

Using the latest nightly build of HeidiSQL, you will get 1 trailing zero by default throuh this new setting:

Description

Please login to leave a reply, or register at first.