WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Strings

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

String Compare Problem


Question:

Why are these strings comparing as the same?
x = "000000000000E1"
y = "000000000000E2"
if x == y then message("Error Test", "Is this a bug?")
I am running WinBatch 2004a.

Answer:

They are being interpreted as floating point numbers in engineering notation.

Both strings are being converted to floating point 0.0

Kinda the same as

x=0
y=00

or

x="0"
y="0000"

Gotta watch out for strings that convert to valid numbers. The == method of comparing is incredibly friendly, but if your input smells like a number, it will do a numeric compare. Which, in some circumstances, is not what you want. If you have issues then try..

x="0000E1"
y="00000000E2"
If StrCmp(x, y) == 0 Then ..
.


Article ID:   W16723
File Created: 2005:02:18:12:22:02
Last Updated: 2005:02:18:12:22:02