Domanda

I am facing a strange problem in crystal report 2008

I have a table (mytable) with two columns col1 is string and col2 is float(15)

Below are values in table

Col1       Col2
AA         5.82518987E-5
BB         5.88383009E-5

Created a report in crystal report and placed mytable values on report for col1 it displays correct value but for COL2 it always displays FOR AA "0.0000582519" AND FOR BB "0.0000588383" instead of actual value in the table.

This is what in Crystal report instead of actual value.

Col1       Col2
AA        0.0000582519
BB        0.0000588383

Please help

Thanks

È stato utile?

Soluzione

CR has the interesting limitation that the highest precision numeric value it can display is 10 decimal places (this includes trying to use the totext() function to cast the number to a string). This means that any float over that precision will be rounded at that tenth decimal.

Because of this and the fact that you're using a float which is precise up to 15 digits, the quick and dirty solution is to just manually convert to scientific notation by moving your decimal place over 5. You can accomplish this with something like:

totext({table.numeric} * 10^5,10) & "E-5"

Obviously, this will just indiscriminately convert all your numbers in Col2 to scientific notation whether they require it or not, so you may wish to add some additional conditional processing.

Note that if you Google "Crystal Reports scientific notation" you can find some custom functions to do that for you... but just be careful because a lot of these functions do not take the additional precision into account and WILL result in a much less precise number. In fact, the very first hit (HOw to display Number in Scientific Notation in version 2008) will chop that precision down to 10 digits in the very first line by using the totext() function.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top