Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String = 0 problem

Status
Not open for further replies.

XTnCIS

Programmer
Apr 23, 2002
57
0
0
US
I wrote a function called isbarren() that takes a variable and checks isnull, isempty, = "", and = 0 and returns TRUE or FALSE.

I've used it happily until yesterday when I noticed that when I pass a string value of "2000D-473" it returned TRUE.

Upon examination, I discovered that ' ? "2000D-473" = 0 will return true...

Anybody know why? I guess there is some implicit conversion going on and the computer looks at the dash as a negative sign, but "2000D-309" = 0 returns FALSE.
 
It appears that the number of being interpreted as a scientific notion format. What is strange is that the letter D seems to have the same meaning as the more commonly used E for the scientific number format. But the results seem to be the same.

If you change the the "-" to a "+" then you get an overflow at +305. Which makes since since 2000E+305 execeeds the maximum 1797E+305 for a double precision number. Similarly, the lower possible number is 4.947E-324, which is the same as 4974E-327. Anything less than that is for all practical purposes 0, thus you get 0=0 True return. So with a mantissa of 2000D, and power from 327 on up will be less than the minimum value, which is why ("2000D-473" = 0) returns True.

The interesting part is that the "D" is treated the same as "E" in interpreting this format as a scientific notation number.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Interesting because I just copied your value into my debug window (A2000) and it returned
2000D-473

Can't imagine that will help but maybe it won't hurt to know.

Paul

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top