Display number value as Scientific Notation in a dbgrid
Posted on 2014-09-22
We display scientific data in a dbgrid. If the numeric value is outside the bounds (<.0001 and >10000.00), the number is displayed in Scientific Notation,otherwise it is displayed as a regular float. The field needs to be editable as either a float or scientific notation (the user must be able to enter an 'E+' or 'E-'.
We have attempted to use getText (testing the bounds then setting the format), it went into a recursive loop. We then tried the Validate which performed the conversion (adding 3 to the exponent (BAD)) and then set the format for ALL the rows in the column, even those that fell in the bounds (BAD), to sci-note.
value sci-note should be
.005 -> 5.e-006 0.005
.0000000006 6E-13 6.00 E-10
The value is stored in Oracle as a NUMBER. Oracle(TOAD) displays the value correctly for sci-note and float.
It worked in the OLD C++Builder without any fuss.
Scientific numbers must be precise if we have to manually process the number each time, we may loose something (significant digits) in the translation.
What do we do?
We have XE4, TMS Component Pack, FireDac and Oracle