JayeP
JayeP

Reputation: 11

Convert scientific notation to number to do math

My Crystal Reports experience is limited. Once we have reports in place, years may pass before modification is required and have to delve back in to CR. Presently, I have two fields in database that I need to covert to numbers to divide one by the other. Example of Field1 is '0.00000850 V'; example of Field2 is '9.5e-007 V'. How do you go about converting these to numbers in order to do the math.

Have not been able to solve

Upvotes: -1

Views: 44

Answers (1)

MilletSoftware
MilletSoftware

Reputation: 4026

Assuming the " V" at the end is always there, we can simply remove the last 2 characters. So use something like this:

local stringvar SciNum := Left({SciNum_Raw}, Len({SciNum_Raw}) -2);

local stringvar array SciNum_Array := Split(SciNum, "e");

IF (UBound(SciNum_Array) = 2) Then cDbl(SciNum_Array[1]) * 10^cDbl(SciNum_Array[2])
ELSE 0; 

Upvotes: 0

Related Questions